Ask Question

Function Name: doubles Parameters: list of int Returns: list of int Description: Write a function, doubles, that takes a list of integers and finds values in the list that are exactly twice the previous integer in the list. Return a list of integers from the parameter that meet the criteria specified.

+2
Answers (1)
  1. 3 May, 04:50
    0
    def doubles (numbers):

    double_numbers = []

    for i in range (len (numbers) - 1):

    if numbers[i+1] = = numbers[i] * 2:

    double_numbers. append (numbers[i+1])

    return double_numbers

    Explanation:

    *The code is in Python.

    Create a function called doubles that takes one parameter, numbers

    Initialize an empty list, double_numbers, to hold the double values in the numbers that are exactly twice the previous integer

    Create a for loop that iterates through the numbers

    If the value of the integer is exactly twice the previous integer, add the integer to the double_numbers using append function

    When the loop is done, return the double_numbers
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Function Name: doubles Parameters: list of int Returns: list of int Description: Write a function, doubles, that takes a list of integers ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers