Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Write a program that includes a function, doubles(), that takes as input a list of integers and outputs the integers in the list that

image text in transcribed

1. Write a program that includes a function, doubles(), that takes as input a list of integers and 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, the program will pass the list to the doubles() function as argument. Include the following in your program: 1. Prompt the user for a list of integers 2 pts 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 2 pts 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 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

The Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

More Books

Students also viewed these Databases questions

Question

4. Devise an interview strategy from the interviewers point of view

Answered: 1 week ago