Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a function doubles() that takes as a list of integers as a parameter and p

ID: 3670626 • Letter: W

Question

Write a function doubles() that takes as a list of integers as a parameter and prints the values in the list, one per line, that are exactly twice the previous value in the list. If the list is empty or there are no values that are double the value of their predecessor, then the function does not print anything. The list provided as a parameter should not be changed. Note that the first item in the list will never be printed since it does not have a predecessor in the list. The following shows how the function could be used on several examples:

Explanation / Answer

def doubles(integers): index = 0 for index in range(1,len(integers)): if integers[index] == 2*integers[index-1]: print(integers[index])

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote