Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NEED HELP ON THE WHOLE PROGRAM PLEASE! THANK YOU. Write a Python program that (1) First create an empty list, and use a while loop

NEED HELP ON THE WHOLE PROGRAM PLEASE! THANK YOU.

image text in transcribed

Write a Python program that (1) First create an empty list, and use a while loop to add consecutive numbers '137' to '173' to the list using the append method (augmented assignment operator "+=" will be used to iterate over these numbers). Print the generated list. (2) Use the index method to get the index of numbers '145' and 161, print the two indexes (3) Use the slicing expression to extract a slice of the list from the number 145' to the number '161' (You need to use the results obtained from step (2)). Print the extracted slice (4) Use the in operator to detect if 155' is in the slice, print the result (true/false). The generated list is [137, 138, 139, 140, 141, 142, 143, 144, 14 5, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 15 8, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 17 1, 172, 173] 1st index is 8 2nd index is 24 The extracted slice is [145, 146, 147, 148, 149, 150, 151, 152, 1 53, 154, 155, 156, 157, 158, 159, 160, 161] Whether the slice contains 155 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

T Sql Fundamentals

Authors: Itzik Ben Gan

4th Edition

0138102104, 978-0138102104

More Books

Students also viewed these Databases questions