Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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,

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions