Data_Structures and loops in python lang

Vaishnaviyadav171857 1 views 12 slides Sep 27, 2025
Slide 1
Slide 1 of 12
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12

About This Presentation

python topics which covers data structure & loops


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

Python Lists fruits = ["apple", "banana", "mango", "apple"] print(fruits) ✅ Ordered ✅ Mutable (can change) ✅ Allows duplicates

Looping through a List for fruit in fruits: print(fruit) âž¡ Loops allow us to repeat actions without writing code multiple times.

Python Tuples numbers = (10, 20, 30, 10) print(numbers) ✅ Ordered ✅ Immutable (cannot change) ✅ Allows duplicates

Looping through a Tuple (While Loop) i = 0 while i < len(numbers): print(numbers[i]) i += 1 âž¡ while loop continues until condition becomes False.

Python Sets colors = {"red", "blue", "green", "red"} print(colors) ✅ Unordered ✅ No duplicates

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 ✨