Array Exercises

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Exercises

1. Create an empty list called my_list.Append the numbers 1, 2, and 3 to my_list. Insert
the number 4 at the beginning of my_list. Print the updated my_list.
2. Given the list my_list = [4, 1, 2, 3], remove the number 2 from the list.Use pop() to
remove the last element from my_list.Print the updated my_list.
3. Find the index of the number 1 in my_list[3,4,5,6,7].Print the index.
4. Sort the list my_list in ascending order.Print the sorted list.Reverse the sorted
list.Print the reversed list.
5. Find and print the length of my_list [2,3,4,7,8,9,10].
6. Count how many times 2 appears in my_list [2,4,3,2,2,2,2,2,2,2].
7. Print even numbers from 2 to 20.
8. Sum numbers from 1 to 15.
9. Print numbers from 8 to 1 in reverse order.
10. Print multiples of 3 from 3 to 30 with an increment of 3.
11. Print numbers from 1 to 10.

12. Print numbers from 20 to 4 with a decrement of 2.


13. Create a list of colors. Use the pop() method to remove and print the third element
from the list.
14. Create a list of your colors. Print 4rd element and 5th elements of list.
15. Create a list of days. Use the clear() method to empty the list and print the result.
16. Inserts an element at a specified position list =[1,2,4,5].
18. Print all elements of a list:[1,2,3,4,5] using while loop.

You might also like