🎯 Your first practice
Before we go further, create a small Python file and try these without looking back at the answers:
Exercise 1
Create a list containing 5 numbers and print the first, third, and last elements.
Exercise 2
Create:
[10, 20, 30]
Change 20 to 25.
Exercise 3
Start with:
names = ["Alice", "Bob"]
Add "Charlie" to the end.
Exercise 4
Start with:
numbers = [10, 20, 30, 40]
Remove 30.
Exercise 5 ⭐
Given:
numbers = [10, 20, 30, 40, 50]
use a for loop to print every element.
Your first practice
Try these yourself:
-
Create a tuple containing 5 numbers and print the second and last elements.
-
Try changing one element of the tuple. Observe the error.
-
Loop through a tuple and print every element.
-
Create:
person = ("Sarbesh", 24, "Developer")
Then unpack it into three variables:
name, age, profession = person
and print them.