Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab4 (10pts) Lab submission details 1. Write a program that includes a function, doubles(), that takes as input a list of integers and Important: If

image text in transcribed

Lab4 (10pts) Lab submission details 1. Write a program that includes a function, doubles(), that takes as input a list of integers and Important: If your program does not run, that's an automatic 50% deduction outputs the integers in the list that are exactly twice the previous integer in the list, one per line. The program will prompt the user to enter a list of integers. Once the list is entered, Write your program as a Python script. Use the following naming convention: the program will pass the list to the doubles() function as argument. firstinitial_lastname_lab4.py. Example: P_saweh_lab4.py. Include the following in your program: 1. Prompt the user for a list of integers 2pts Once your program is complete, submit it in D2L. Upload your program file into lab4 a. The list must be read in and stored as a list 2. Display the list entered 1pt 3. Define function doubles() that takes one parameter 2pts 4. Use a loop in the function to determine the integers in the list that are twice the previous integer in the list 2pts a. Don't do any check on the iteration of the loop, because the loop will be at the first value in the list b. For subsequent iterations, check whether the value at the current index in the list is equal to the value in the previous index multiplied by 2 c. Display one integer per line 5. Include selection (if) in your function logic 1pt 6. Call function doubles() 1pt 7. Pass the list to function doubles() 1pt Example Program Run: Enter a list containing integers: [3,0,1,2,3,6,2,4,5,6,5] List entered: [3,0,1,2,3,6,2,4,5,6,5] Numbers that are double the previous value in the list: 2 6 4

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions