Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON 2. Write a function doubles that takes as a list of integers as a parameter and returns a list that contains all values in

PYTHON

2. Write a function doubles that takes as a list of integers as a parameter and returns a list that contains all values in the given list 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 returns an empty list. 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. Sample usage: >>> doubles( [4,8,-12,-24,48,3,6,12,24,2]) [8, -24, 6, 12, 24] >>> doubles([1,2,3,4,5]) [2] >>> doubles([]) [] >>>

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

More Books

Students also viewed these Databases questions

Question

How do they look and behave?

Answered: 1 week ago

Question

How do you feel when they are talking with you?

Answered: 1 week ago

Question

What coaching do you currently provide for your leaders?

Answered: 1 week ago