π―Day 2/30 of AI & ML Learning Journey - python(basic) Conditions, Loops & Functionsππ€
DAY 3 (DETAILED): Lists, Tuples, Sets & Dictionaries
with Manipulation & Predefined Functions
β± Time: 3β3.5 hours
π― Goal:
Store, access, modify, and process data
Use built-in functions confidently
Prepare for NumPy, Pandas, ML datasets
πΉ 1οΈβ£ LIST (Most Important for ML)
What is a List?
Ordered
Mutable (changeable)
Allows duplicates
Copy code
Python
numbers = [10, 20, 30, 40]
π§ List Manipulation
Access
Copy code
Python
numbers[0] # first element
numbers[-1] # last element
Modify
Copy code
Python
numbers[1] = 25
Add elements
Copy code
Python
numbers.append(50)
numbers.insert(1, 15)
Remove elements
Copy code
Python
numbers.remove(30)
numbers.pop()
numbers.pop(0)
π§ Predefined List Functions
Copy code
Python
len(numbers)
max(numbers)
min(numbers)
sum(numbers)
sorted(numbers)
Copy code
Python
numbers.sort()
numbers.reverse()
π Loop + List
Copy code
Python
for num in numbers:
print(num)
π ML Insight
Feature values, predictions, labels β all start as lists.
πΉ 2οΈβ£ TUPLE (Safe, Fixed Data)
What is a Tuple?
Ordered
Immutable (cannot change)
Copy code
Python
points = (10, 20, 30)
Tuple Operations
Copy code
Python
points[0]
len(points)
max(points)
min(points)
β This will fail:
Copy code
Python
points[0] = 100
π Use case: Fixed configuration, coordinates, constants.
πΉ 3οΈβ£ SET (Unique Values Only)
What is a Set?
Unordered
No duplicates
Fast lookup
Copy code
Python
nums = {1, 2, 2, 3, 4}
π§ Set Manipulation
Copy code
Python
nums.add(5)
nums.remove(2)
nums.discard(10) # no error
π§ Predefined Set Functions
Copy code
Python
len(nums)
Set Operations (VERY IMPORTANT)
Copy code
Python
a = {1, 2, 3}
b = {3, 4, 5}
a.union(b)
a.intersection(b)
a.difference(b)
π ML Insight: Remove duplicates, find common categories.
πΉ 4οΈβ£ DICTIONARY (MOST IMPORTANT π₯π₯)
What is a Dictionary?
Key β Value structure
Used in APIs, ML models, JSON
Copy code
Python
student = {
"name": "Rakesh",
"age": 21,
"course": "AI/ML"
}
π§ Dictionary Manipulation
Access
Copy code
Python
student["name"]
student.get("age")
Modify / Add
Copy code
Python
student["age"] = 22
student["city"] = "Bangalore"
Delete
Copy code
Python
student.pop("city")
del student["course"]
π§ Predefined Dictionary Functions
Copy code
Python
student.keys()
student.values()
student.items()
len(student)
π Loop Dictionary
Copy code
Python
for key, value in student.items():
print(key, ":", value)
Dictionary + Function
Copy code
Python
def show_student(data):
for k, v in data.items():
print(k, v)
show_student(student)
π ML Insight:
Model parameters, hyperparameters, API responses β dictionaries.
πΉ 5οΈβ£ Conversion Between Structures (IMPORTANT)
Copy code
Python
list(nums)
set(numbers)
tuple(numbers)
π Used heavily in data preprocessing.
πΉ 6οΈβ£ Mini Practice (Hands-On)
1οΈβ£ Sort a list and find max
2οΈβ£ Convert list β set to remove duplicates
3οΈβ£ Count items using dictionary
4οΈβ£ Pass list/dict into function
πΉ 7οΈβ£ End-of-Day Challenge (π₯)
Problem:
β Input list of numbers
β Remove duplicates
β Store result in dictionary
Copy code
Python
def process_data(data):
unique = set(data)
return {
"original": data,
"unique": unique,
"count": len(unique)
}
print(process_data([1,2,2,3,4]))
π§ DAY 3 CHECKLIST β
β List manipulation
β Used built-in functions
β Used set operations
β Dictionary CRUD operations
π‘ Pro Tip (AI/ML POV)
Data preprocessing = 70% of ML work
This day decides your ML future
with Manipulation & Predefined Functions
β± Time: 3β3.5 hours
π― Goal:
Store, access, modify, and process data
Use built-in functions confidently
Prepare for NumPy, Pandas, ML datasets
πΉ 1οΈβ£ LIST (Most Important for ML)
What is a List?
Ordered
Mutable (changeable)
Allows duplicates
Copy code
Python
numbers = [10, 20, 30, 40]
π§ List Manipulation
Access
Copy code
Python
numbers[0] # first element
numbers[-1] # last element
Modify
Copy code
Python
numbers[1] = 25
Add elements
Copy code
Python
numbers.append(50)
numbers.insert(1, 15)
Remove elements
Copy code
Python
numbers.remove(30)
numbers.pop()
numbers.pop(0)
π§ Predefined List Functions
Copy code
Python
len(numbers)
max(numbers)
min(numbers)
sum(numbers)
sorted(numbers)
Copy code
Python
numbers.sort()
numbers.reverse()
π Loop + List
Copy code
Python
for num in numbers:
print(num)
π ML Insight
Feature values, predictions, labels β all start as lists.
πΉ 2οΈβ£ TUPLE (Safe, Fixed Data)
What is a Tuple?
Ordered
Immutable (cannot change)
Copy code
Python
points = (10, 20, 30)
Tuple Operations
Copy code
Python
points[0]
len(points)
max(points)
min(points)
β This will fail:
Copy code
Python
points[0] = 100
π Use case: Fixed configuration, coordinates, constants.
πΉ 3οΈβ£ SET (Unique Values Only)
What is a Set?
Unordered
No duplicates
Fast lookup
Copy code
Python
nums = {1, 2, 2, 3, 4}
π§ Set Manipulation
Copy code
Python
nums.add(5)
nums.remove(2)
nums.discard(10) # no error
π§ Predefined Set Functions
Copy code
Python
len(nums)
Set Operations (VERY IMPORTANT)
Copy code
Python
a = {1, 2, 3}
b = {3, 4, 5}
a.union(b)
a.intersection(b)
a.difference(b)
π ML Insight: Remove duplicates, find common categories.
πΉ 4οΈβ£ DICTIONARY (MOST IMPORTANT π₯π₯)
What is a Dictionary?
Key β Value structure
Used in APIs, ML models, JSON
Copy code
Python
student = {
"name": "Rakesh",
"age": 21,
"course": "AI/ML"
}
π§ Dictionary Manipulation
Access
Copy code
Python
student["name"]
student.get("age")
Modify / Add
Copy code
Python
student["age"] = 22
student["city"] = "Bangalore"
Delete
Copy code
Python
student.pop("city")
del student["course"]
π§ Predefined Dictionary Functions
Copy code
Python
student.keys()
student.values()
student.items()
len(student)
π Loop Dictionary
Copy code
Python
for key, value in student.items():
print(key, ":", value)
Dictionary + Function
Copy code
Python
def show_student(data):
for k, v in data.items():
print(k, v)
show_student(student)
π ML Insight:
Model parameters, hyperparameters, API responses β dictionaries.
πΉ 5οΈβ£ Conversion Between Structures (IMPORTANT)
Copy code
Python
list(nums)
set(numbers)
tuple(numbers)
π Used heavily in data preprocessing.
πΉ 6οΈβ£ Mini Practice (Hands-On)
1οΈβ£ Sort a list and find max
2οΈβ£ Convert list β set to remove duplicates
3οΈβ£ Count items using dictionary
4οΈβ£ Pass list/dict into function
πΉ 7οΈβ£ End-of-Day Challenge (π₯)
Problem:
β Input list of numbers
β Remove duplicates
β Store result in dictionary
Copy code
Python
def process_data(data):
unique = set(data)
return {
"original": data,
"unique": unique,
"count": len(unique)
}
print(process_data([1,2,2,3,4]))
π§ DAY 3 CHECKLIST β
β List manipulation
β Used built-in functions
β Used set operations
β Dictionary CRUD operations
π‘ Pro Tip (AI/ML POV)
Data preprocessing = 70% of ML work
This day decides your ML future
β€3
WebCoper_Day_4_NumPy_Arrays (1).pdf
4.9 KB
DAY 4 β NumPy Arrays (ML Starts Here)
Palantir article π
-> https://www.theguardian.com/commentisfree/2025/aug/24/palantir-artificial-intelligence-civil-rights
-> https://www.theguardian.com/commentisfree/2025/aug/24/palantir-artificial-intelligence-civil-rights
the Guardian
Palantirβs tools pose an invisible danger we are just beginning to comprehend | Juan Sebastian Pinto
Weaponized AI surveillance platforms threaten human rights around the world. Hereβs how they work
GitHub Foundations Certification βοΈ https://education.github.com/experiences/foundations_certificate
β€2