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

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

Skip to main content

Lesson 8 - Assignment

Objective:

Understand how to create, access, modify, and manipulate lists in Python.

Tasks:

1.    Create and Print a List:

o   Create a list named fruits with at least 5 fruits.

o   Print the list and its length.

2.    Access and Modify Items:

o   Print the first and last items using indexing.

o   Replace the second fruit with "blueberry" and print the updated list.

3.    Slicing:

o   Use slicing to print the 2nd to 4th items.

4.    Check Existence:

o   Check if "apple" is in the list and print "Yes" or "No" accordingly.

5.    Add and Remove Items:

o   Add a new fruit to the end using append().

o   Insert a fruit at index 2 using insert().

o   Remove a fruit using remove().

o   Remove the last item using pop().