๐ ๐๐ & ๐ ๐ฎ๐ฐ๐ต๐ถ๐ป๐ฒ ๐๐ฒ๐ฎ๐ฟ๐ป๐ถ๐ป๐ด ๐๐ฅ๐๐ ๐๐ฒ๐ฟ๐๐ถ๐ณ๐ถ๐ฐ๐ฎ๐๐ถ๐ผ๐ป ๐๐ผ๐๐ฟ๐๐ฒ๐ฅ
Learn the most in-demand AI skills from scratch and strengthen your profile with industry-recognized certificates! ๐
โ Beginner-Friendly Courses
โ Learn Online at Your Own Pace
โ 100% FREE of cost
Perfect for Students, Freshers & Working Professionals looking to build a career in AI/ML. ๐ผ
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/4phANS2
๐ข Share this with your friends who want to start their AI career!
Learn the most in-demand AI skills from scratch and strengthen your profile with industry-recognized certificates! ๐
โ Beginner-Friendly Courses
โ Learn Online at Your Own Pace
โ 100% FREE of cost
Perfect for Students, Freshers & Working Professionals looking to build a career in AI/ML. ๐ผ
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/4phANS2
๐ข Share this with your friends who want to start their AI career!
โค1
๐ Data Science Roadmap 2026
๐ Phase 1: Programming Fundamentals
๐ Topic 7: Python Data Structures (Lists, Tuples, Sets & Dictionaries)
Welcome back! ๐
So far, you've learned variables, operators, input/output, conditional statements, loops, and functions. Now it's time to learn one of the most important topics in Pythonโ Data Structures.
Data structures help us store, organize, and manage data efficiently. In Data Science, almost every dataset you work with will be stored or manipulated using these structures.
Python provides four built-in data structures:
โข List
โข Tuple
โข Set
โข Dictionary
Let's understand each one in detail.
๐น 1. List
A List is an ordered, mutable collection that allows duplicate values.
Creating a List
Output
Accessing Elements
Output
Modifying a List
Output
Adding Elements
Removing Elements
๐น 2. Tuple
A Tuple is an ordered collection that cannot be modified after creation (immutable).
Creating a Tuple
Accessing Elements
Output
Why Use Tuples?
Use tuples when your data should never change.
Examples:
โข Months of the year
โข Days of the week
โข Fixed coordinates
๐น 3. Set
A Set is an unordered collection of unique elements.
Duplicate values are automatically removed.
Creating a Set
Output
Adding Elements
Removing Elements
Common Uses
โข Remove duplicates
โข Membership testing
โข Mathematical set operations
๐น 4. Dictionary โญ
A Dictionary stores data as key-value pairs.
It is one of the most frequently used data structures in Data Science.
Creating a Dictionary
Accessing Values
Output
Adding a New Key
Updating a Value
Removing a Key
๐น 5. Comparison of Data Structures
Feature | List | Tuple | Set | Dictionary
Ordered | โ | โ | โ | โ
Mutable | โ | โ | โ | โ
Duplicates Allowed | โ | โ | โ | Keys โ
Indexed | โ | โ | โ | By Key
๐น 6. Common List Methods
๐น 7. Common Dictionary Methods
๐ Phase 1: Programming Fundamentals
๐ Topic 7: Python Data Structures (Lists, Tuples, Sets & Dictionaries)
Welcome back! ๐
So far, you've learned variables, operators, input/output, conditional statements, loops, and functions. Now it's time to learn one of the most important topics in Pythonโ Data Structures.
Data structures help us store, organize, and manage data efficiently. In Data Science, almost every dataset you work with will be stored or manipulated using these structures.
Python provides four built-in data structures:
โข List
โข Tuple
โข Set
โข Dictionary
Let's understand each one in detail.
๐น 1. List
A List is an ordered, mutable collection that allows duplicate values.
Creating a List
fruits = ["Apple", "Banana", "Mango"]
print(fruits)
Output
['Apple', 'Banana', 'Mango']
Accessing Elements
print(fruits[0])
print(fruits[2])
Output
Apple
Mango
Modifying a List
fruits[1] = "Orange"
print(fruits)
Output
['Apple', 'Orange', 'Mango']
Adding Elements
fruits.append("Grapes")
print(fruits)Removing Elements
fruits.remove("Orange")
print(fruits)๐น 2. Tuple
A Tuple is an ordered collection that cannot be modified after creation (immutable).
Creating a Tuple
colors = ("Red", "Green", "Blue")
print(colors)Accessing Elements
print(colors[1])
Output
Green
Why Use Tuples?
Use tuples when your data should never change.
Examples:
โข Months of the year
โข Days of the week
โข Fixed coordinates
๐น 3. Set
A Set is an unordered collection of unique elements.
Duplicate values are automatically removed.
Creating a Set
numbers = {1, 2, 2, 3, 4, 4, 5}
print(numbers)Output
{1, 2, 3, 4, 5}Adding Elements
numbers.add(6)
Removing Elements
numbers.remove(3)
Common Uses
โข Remove duplicates
โข Membership testing
โข Mathematical set operations
๐น 4. Dictionary โญ
A Dictionary stores data as key-value pairs.
It is one of the most frequently used data structures in Data Science.
Creating a Dictionary
student = {
"name": "Deepak",
"age": 24,
"course": "Data Science"
}
print(student)Accessing Values
print(student["name"])
Output
Deepak
Adding a New Key
student["city"] = "Mumbai"
Updating a Value
student["age"] = 25
Removing a Key
del student["course"]
๐น 5. Comparison of Data Structures
Feature | List | Tuple | Set | Dictionary
Ordered | โ | โ | โ | โ
Mutable | โ | โ | โ | โ
Duplicates Allowed | โ | โ | โ | Keys โ
Indexed | โ | โ | โ | By Key
๐น 6. Common List Methods
numbers = [10, 20, 30]
numbers.append(40)
numbers.insert(1, 15)
numbers.remove(20)
numbers.sort()
print(numbers)
๐น 7. Common Dictionary Methods
โค3
student = {
"name": "Rahul",
"age": 23
}
print(student.keys())
print(student.values())
print(student.items())๐น 8. Real-World Data Science Example
Suppose you have student information.
students = [
{"name": "Amit", "marks": 90},
{"name": "Sara", "marks": 85}
]
for student in students:
print(student["name"], student["marks"])
Output
Amit 90
Sara 85
This is very similar to how records are stored before converting them into a Pandas DataFrame.
๐น 9. Common Mistakes
โ Trying to Modify a Tuple
colors = ("Red", "Green")
colors[0] = "Blue"This raises a
TypeError because tuples are immutable.โ Accessing a Missing Dictionary Key
student = {"name": "John"}
print(student["age"])This raises a
KeyError.A safer approach:
print(student.get("age"))๐ฏ Practice Questions
1. Create a list of five cities and print the third city.
2. Create a tuple containing the days of the week.
3. Remove duplicate numbers from a list using a set.
4. Create a dictionary containing your name, age, and profession.
5. Print all keys and values of a dictionary using a loop.
๐ฏ Key Takeaways
โ Lists are ordered and mutable.
โ Tuples are ordered and immutable.
โ Sets store only unique values.
โ Dictionaries store data as key-value pairs.
โ Dictionaries and Lists are the most commonly used data structures in Data Science.
Mastering these four data structures will make it much easier to work with datasets, APIs, JSON files, and machine learning projects.
Double Tap โค๏ธ For Part-8
โค8
๐ ๐๐ถ๐๐ฐ๐ผ ๐๐ฅ๐๐ ๐ง๐ฒ๐ฐ๐ต ๐๐ผ๐๐ฟ๐๐ฒ๐ | ๐ฑ ๐ ๐๐๐-๐๐ผ ๐๐ผ๐๐ฟ๐๐ฒ๐ ๐
Cisco offers learning opportunities covering some of the most valuable foundations for careers in Cybersecurity, Networking, Linux and IoT.
โ Beginner-Friendly Tech Skills
โ Learn In-Demand IT Concepts
โ Build Practical Knowledge
โ Strengthen Your Resume
โ Great for Students & Freshers
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/4fhCSKo
๐ฅ Learn from Cisco โข Build Skills โข Upgrade Your Resume โข Get Career-Ready!
Cisco offers learning opportunities covering some of the most valuable foundations for careers in Cybersecurity, Networking, Linux and IoT.
โ Beginner-Friendly Tech Skills
โ Learn In-Demand IT Concepts
โ Build Practical Knowledge
โ Strengthen Your Resume
โ Great for Students & Freshers
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/4fhCSKo
๐ฅ Learn from Cisco โข Build Skills โข Upgrade Your Resume โข Get Career-Ready!
โค1
Which Python data structure is ordered, mutable, and allows duplicate values?
Anonymous Quiz
9%
A) Set
24%
B) Tuple
59%
C) List
8%
D) Dictionary
๐2โค1
Which data structure stores only unique elements?
Anonymous Quiz
8%
A) List
28%
B) Tuple
45%
C) Set
18%
D) Dictionary
๐2โค1
Which statement about tuples is correct?
Anonymous Quiz
10%
A) Tuples are mutable.
25%
B) Tuples do not allow duplicate values.
61%
C) Tuples are immutable.
3%
D) Tuples are unordered.
โค4
What will be the output of the following code?
numbers = {1, 2, 2, 3, 4, 4}
print(len(numbers))
numbers = {1, 2, 2, 3, 4, 4}
print(len(numbers))
Anonymous Quiz
33%
4
15%
5
50%
6
2%
7
โค5
๐๐ & ๐๐ฎ๐๐ฎ ๐ฆ๐ฐ๐ถ๐ฒ๐ป๐ฐ๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ (๐ก๐ผ ๐๐ผ๐ฑ๐ถ๐ป๐ด ๐ก๐ฒ๐ฒ๐ฑ๐ฒ๐ฑ)
Apply Now๐:- https://pdlink.in/4aYWald
By E&ICT Academy, IIT Roorkee
Batch Closing Soon - 26th July 2026
Apply Now๐:- https://pdlink.in/4aYWald
By E&ICT Academy, IIT Roorkee
Batch Closing Soon - 26th July 2026
๐ Data Science Roadmap 2026
๐ Phase 1: Programming Fundamentals
๐ Topic 8: Python List Comprehensions
Welcome back! ๐
In the previous lesson, you learned about Python's built-in data structuresโLists, Tuples, Sets, and Dictionaries.
Now it's time to learn one of Python's most elegant and frequently used features: List Comprehensions.
List comprehensions provide a concise and readable way to create, filter, and transform lists. They are widely used in Data Science, Machine Learning, data preprocessing, and coding interviews.
๐น 1. What is a List Comprehension?
A list comprehension is a compact way to create a new list by applying an expression to each item in an iterable (such as a list, tuple, or range).
Instead of writing multiple lines with a loop, you can accomplish the same task in a single line.
General Syntax
๐น 2. Creating a List Using a Loop
Output
๐น 3. Creating the Same List Using List Comprehension
Output
Notice how the code is shorter and easier to read.
๐น 4. Performing Calculations
Create a list of squares.
Output
๐น 5. Using Conditions
You can filter elements while creating a list.
Example: Even Numbers
Output
๐น 6. Converting Strings
Convert all names to uppercase.
Output
๐น 7. Using Conditional Expressions
Replace negative numbers with zero.
Output
๐น 8. Nested List Comprehension
Create a multiplication table.
Output
๐น 9. Real-World Data Science Example
Suppose you have a list of sales amounts.
Output
This technique is commonly used while cleaning and filtering datasets before analysis.
๐น 10. Benefits of List Comprehensions
โ Shorter code
โ Easier to read
โ Faster than traditional loops in many cases
โ Widely used in Data Science and Machine Learning
๐น 11. Common Mistakes
โ Forgetting the Expression
Correct:
โ Incorrect Order of "if"
Correct:
๐ Phase 1: Programming Fundamentals
๐ Topic 8: Python List Comprehensions
Welcome back! ๐
In the previous lesson, you learned about Python's built-in data structuresโLists, Tuples, Sets, and Dictionaries.
Now it's time to learn one of Python's most elegant and frequently used features: List Comprehensions.
List comprehensions provide a concise and readable way to create, filter, and transform lists. They are widely used in Data Science, Machine Learning, data preprocessing, and coding interviews.
๐น 1. What is a List Comprehension?
A list comprehension is a compact way to create a new list by applying an expression to each item in an iterable (such as a list, tuple, or range).
Instead of writing multiple lines with a loop, you can accomplish the same task in a single line.
General Syntax
new_list = [expression for item in iterable]๐น 2. Creating a List Using a Loop
numbers = []
for i in range(5):
numbers.append(i)
print(numbers)
Output
[0, 1, 2, 3, 4]
๐น 3. Creating the Same List Using List Comprehension
numbers = [i for i in range(5)]
print(numbers)
Output
[0, 1, 2, 3, 4]
Notice how the code is shorter and easier to read.
๐น 4. Performing Calculations
Create a list of squares.
squares = [x ** 2 for x in range(1, 6)]
print(squares)
Output
[1, 4, 9, 16, 25]
๐น 5. Using Conditions
You can filter elements while creating a list.
Example: Even Numbers
even_numbers = [x for x in range(1, 11) if x % 2 == 0]
print(even_numbers)
Output
[2, 4, 6, 8, 10]
๐น 6. Converting Strings
Convert all names to uppercase.
names = ["rahul", "deepak", "anita"]
upper_names = [name.upper() for name in names]
print(upper_names)
Output
['RAHUL', 'DEEPAK', 'ANITA']
๐น 7. Using Conditional Expressions
Replace negative numbers with zero.
numbers = [5, -2, 8, -1, 3]
updated = [0 if x < 0 else x for x in numbers]
print(updated)
Output
[5, 0, 8, 0, 3]
๐น 8. Nested List Comprehension
Create a multiplication table.
table = [[i * j for j in range(1, 6)] for i in range(1, 4)]
print(table)
Output
[[1, 2, 3, 4, 5],
[2, 4, 6, 8, 10],
[3, 6, 9, 12, 15]]
๐น 9. Real-World Data Science Example
Suppose you have a list of sales amounts.
sales = [1200, 850, 1500, 600, 2000]
high_sales = [sale for sale in sales if sale > 1000]
print(high_sales)
Output
[1200, 1500, 2000]
This technique is commonly used while cleaning and filtering datasets before analysis.
๐น 10. Benefits of List Comprehensions
โ Shorter code
โ Easier to read
โ Faster than traditional loops in many cases
โ Widely used in Data Science and Machine Learning
๐น 11. Common Mistakes
โ Forgetting the Expression
numbers = [for i in range(5)] # SyntaxError
Correct:
numbers = [i for i in range(5)]
โ Incorrect Order of "if"
numbers = [if x % 2 == 0 x for x in range(10)] # SyntaxError
Correct:
numbers = [x for x in range(10) if x % 2 == 0]
โค7๐1
๐ฏ Practice Questions
1. Create a list of numbers from 1 to 20.
2. Create a list containing the squares of numbers from 1 to 10.
3. Create a list containing only odd numbers from 1 to 20.
4. Convert a list of names to lowercase.
5. Replace all negative values in a list with zero using a list comprehension.
๐ฏ Key Takeaways
โ List comprehensions provide a concise way to create lists.
โ They combine loops and expressions into a single line.
โ You can filter data using "if" conditions.
โ Conditional expressions allow values to be modified during list creation.
โ List comprehensions are widely used in data cleaning, feature engineering, and machine learning workflows.
Mastering list comprehensions will help you write cleaner, more Pythonic code and prepare you for technical interviews and real-world Data Science projects.
Double Tap โค๏ธ For Part-9
1. Create a list of numbers from 1 to 20.
2. Create a list containing the squares of numbers from 1 to 10.
3. Create a list containing only odd numbers from 1 to 20.
4. Convert a list of names to lowercase.
5. Replace all negative values in a list with zero using a list comprehension.
๐ฏ Key Takeaways
โ List comprehensions provide a concise way to create lists.
โ They combine loops and expressions into a single line.
โ You can filter data using "if" conditions.
โ Conditional expressions allow values to be modified during list creation.
โ List comprehensions are widely used in data cleaning, feature engineering, and machine learning workflows.
Mastering list comprehensions will help you write cleaner, more Pythonic code and prepare you for technical interviews and real-world Data Science projects.
Double Tap โค๏ธ For Part-9
โค8
๐ ๐๐ถ๐๐ฐ๐ผ ๐๐ฅ๐๐ ๐ง๐ฒ๐ฐ๐ต ๐๐ผ๐๐ฟ๐๐ฒ๐ | ๐ฑ ๐ ๐๐๐-๐๐ผ ๐๐ผ๐๐ฟ๐๐ฒ๐ ๐
Cisco offers learning opportunities covering some of the most valuable foundations for careers in Cybersecurity, Networking, Linux and IoT.
โ Beginner-Friendly Tech Skills
โ Learn In-Demand IT Concepts
โ Build Practical Knowledge
โ Strengthen Your Resume
โ Great for Students & Freshers
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/4fhCSKo
๐ฅ Learn from Cisco โข Build Skills โข Upgrade Your Resume โข Get Career-Ready!
Cisco offers learning opportunities covering some of the most valuable foundations for careers in Cybersecurity, Networking, Linux and IoT.
โ Beginner-Friendly Tech Skills
โ Learn In-Demand IT Concepts
โ Build Practical Knowledge
โ Strengthen Your Resume
โ Great for Students & Freshers
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/4fhCSKo
๐ฅ Learn from Cisco โข Build Skills โข Upgrade Your Resume โข Get Career-Ready!
โค2
๐ฐ 3 years of experience. Still waiting for a salary jump?
Experience alone doesn't guarantee growth.
Learning in-demand skills can help you stay competitive in today's job market.
That's why people are joining E&ICT Academy IIT Roorkee's AI & ML Program.
โ 6 Months | Online | Open for all backgrounds
โ Learn from IIT professors & industry mentors
โ Flipkart & Mamaearth projects
โ Placement support through Masai's network of 5000+ companies
๐ Entrance Test: 26th July
๐ https://tinyurl.com/DS-26Jul-006
Experience alone doesn't guarantee growth.
Learning in-demand skills can help you stay competitive in today's job market.
That's why people are joining E&ICT Academy IIT Roorkee's AI & ML Program.
โ 6 Months | Online | Open for all backgrounds
โ Learn from IIT professors & industry mentors
โ Flipkart & Mamaearth projects
โ Placement support through Masai's network of 5000+ companies
๐ Entrance Test: 26th July
๐ https://tinyurl.com/DS-26Jul-006
โค5
๐ ๐ ๐ฎ๐๐๐ฒ๐ฟ ๐ฆ๐ค๐ ๐๐ผ๐ฟ ๐๐ฅ๐๐! ๐๏ธ๐ป
Start learning SQL with these 100% FREE resources and build one of the most in-demand skills in tech!
โ Beginner-Friendly SQL Tutorials
โ FREE Online SQL Courses
โ Interactive SQL Practice Platforms
โ Real-World Database Projects
โ Interview Preparation Resources
โ Hands-on Exercises & Challenges
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/4yLrNci
๐ Start your SQL journey today and unlock exciting career opportunities!
Start learning SQL with these 100% FREE resources and build one of the most in-demand skills in tech!
โ Beginner-Friendly SQL Tutorials
โ FREE Online SQL Courses
โ Interactive SQL Practice Platforms
โ Real-World Database Projects
โ Interview Preparation Resources
โ Hands-on Exercises & Challenges
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/4yLrNci
๐ Start your SQL journey today and unlock exciting career opportunities!
โค4
Data Science & Machine Learning
๐ฐ 3 years of experience. Still waiting for a salary jump? Experience alone doesn't guarantee growth. Learning in-demand skills can help you stay competitive in today's job market. That's why people are joining E&ICT Academy IIT Roorkee's AI & ML Program.โฆ
Last 6 Hours Remaining!
Before the application closes for E&ICT IIT Roorkee AI & ML Program.
Don't miss out on the chance to:
โข Learn live from IIT professors & industry experts
โข Build real AI projects
โข Get Placement Support from Masai.
Register NOW
Before the application closes for E&ICT IIT Roorkee AI & ML Program.
Don't miss out on the chance to:
โข Learn live from IIT professors & industry experts
โข Build real AI projects
โข Get Placement Support from Masai.
Register NOW
โค2๐1
๐ ๐๐๐ฏ๐ฒ๐ฟ๐๐ฒ๐ฐ๐๐ฟ๐ถ๐๐ & ๐๐น๐ผ๐๐ฑ ๐๐ผ๐บ๐ฝ๐๐๐ถ๐ป๐ด ๐๐ฅ๐๐ ๐๐ฒ๐ฟ๐๐ถ๐ณ๐ถ๐ฐ๐ฎ๐๐ถ๐ผ๐ป ๐๐ผ๐๐ฟ๐๐ฒ๐
Build job-ready skills in two of the most in-demand technology fields and strengthen your rรฉsumรฉ with valuable certifications! ๐
๐ Cyber Security :- https://pdlink.in/4bHIF9K
โ
โ๏ธ Cloud Computing :- https://pdlink.in/4yXs8bU
โ
Perfect for Students, Freshers & Working Professionals looking to launch or upgrade their tech careers. ๐ผ
๐ Enroll for FREE & Get Certified
Build job-ready skills in two of the most in-demand technology fields and strengthen your rรฉsumรฉ with valuable certifications! ๐
๐ Cyber Security :- https://pdlink.in/4bHIF9K
โ
โ๏ธ Cloud Computing :- https://pdlink.in/4yXs8bU
โ
Perfect for Students, Freshers & Working Professionals looking to launch or upgrade their tech careers. ๐ผ
๐ Enroll for FREE & Get Certified