-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweek 2
More file actions
51 lines (24 loc) · 918 Bytes
/
week 2
File metadata and controls
51 lines (24 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
OVERVIEW
This Python script demonstrates basic list operations such as appending, inserting, extending, removing, sorting, and finding elements in a list.
STEPS PERFORMED
1. Create an Empty List
Initializes an empty list named my_list.
2. Append Elements
Appends the integers 10, 20, 30, and 40 to my_list.
3. Insert an Element
Inserts the integer 15 at the second position (index 1).
4. Extend the List
Extends my_list with another list [50, 60, 70].
5. Remove the Last Element
Removes the last element in my_list using .pop().
6. Sort the List
Sorts my_list in ascending order.
7. Find the Index of a Value
Finds and prints the index of the value 30 in my_list.
USAGE
Save the script to a file, e.g., list_operations.py.
Run the script with:
python list_operations.py
The output will display the index of the value 30 after all list operations.
EXPECTED OUTPUT
The index of value 30 is: 3