python topics which covers data structure & loops
Size: 37.74 KB
Language: en
Added: Sep 27, 2025
Slides: 12 pages
Slide Content
Data Structures and Loops in Python 🔹 Understanding the basics with examples
What are Data Structures? - A way to organize and store data in Python - Common Data Structures: • List → ordered, changeable, allows duplicates • Tuple → ordered, unchangeable, allows duplicates • Set → unordered, no duplicates • Dictionary → key-value pairs
Looping through a Set for color in colors: print(color) âž¡ Order is not guaranteed in sets.
Python Dictionaries student = {"name": "Alice", "age": 21, "course": "CS"} print(student) ✅ Stores data in key-value pairs ✅ Keys are unique
Looping through a Dictionary for key, value in student.items(): print(key, ":", value) âž¡ Useful for structured data.
Example – Squaring Numbers nums = [1, 2, 3, 4, 5] squares = [] for n in nums: squares.append(n ** 2) print("Squares:", squares) 🎯 Combines list + loop to solve a problem.
Summary - Data Structures help store data effectively. - Loops make code shorter and more efficient. - Together, they form the core of Python programming. ✨ End of Presentation ✨