Question: Write a program which performs the following tasks (1) define a list named num1 and initialize it with the following values: yes, 20, 30, 40,

Write a program which performs the following tasks (1) define a list named num1 and initialize it with the following values: yes, 20, 30, 40, 50, 'no (2) modify the first and last element to 10 and 60 (using their index numbers), respectively. Print the modified list num1. (3) create another list named num2 which has three elements 70,80,90. Then, concatenate num2 to the back of num1 using the + operator. Print the extended list num1. 4) use the append method to add element 100 to the end of the list. Print the appended list num1. (5) Use the index method to get the index of element 30 and 80. Print the two index numbers. (6) Use the slicing expression to extract a slice/subsection of the list starting from the element 30 up to element 80 (80 included), using the results obtained in the previous step. Print the extracted slice. (7) Use the in operator to detect if 70 is in the slice, print the result (True/False). The modified list is [10, 20, 30, 40, 50, 60] The extended list is [10, 20, 30, 40, 50, 60, 70, 80, 90] The appended list is [10, 20, 30, 40, 50, 60, 70, 80, 90, 100] The index numbers are 2 and 7 The extracted slice is [30, 40, 50, 60, 70, 80] Whether does the slice contain 70: True
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
