Ask Question
5 October, 12:53

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.

+4
Answers (1)
  1. 5 October, 15:24
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers