💡 For the best experience, set your browser zoom level to 75%

    ‎75%‎ للحصول على أفضل تجربة، اضبط مستوى تكبير المتصفح على 💡

Skip to main content

Lesson 7 – Assignment

 

Objective:

Use for and while loops, apply break, continue, range(), and loop control structures in Python.

 

Tasks:

1.    For Loop with List:

o   Create a list of fruits: ["apple", "banana", "cherry"]

o   Loop through the list and print each fruit.

2.    Break and Continue:

o   Inside the same loop, if the fruit is "banana", skip it using continue.

o   In another loop, break the loop if the fruit is "cherry".

3.    Using range() Function:

o   Use a for loop with range(1, 11) to print numbers from 1 to 10.

o   Then use range(1, 21, 2) to print odd numbers from 1 to 20.