Skip to content

Latest commit

 

History

History
65 lines (31 loc) · 951 Bytes

File metadata and controls

65 lines (31 loc) · 951 Bytes

🎯 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:

  1. Create a tuple containing 5 numbers and print the second and last elements.

  2. Try changing one element of the tuple. Observe the error.

  3. Loop through a tuple and print every element.

  4. Create:

person = ("Sarbesh", 24, "Developer")

Then unpack it into three variables:

name, age, profession = person

and print them.