Consider the following function: def double_all(numbers): ""Doubles all the elements in the given list. Does not return anything.' for i in range (0, len(numbers)): numbers [i] = numbers [i] * 2 If...


Consider the following function:<br>def double_all(numbers):<br>

Extracted text: Consider the following function: def double_all(numbers): ""Doubles all the elements in the given list. Does not return anything.' for i in range (0, len(numbers)): numbers [i] = numbers [i] * 2 If the main program contains the two statements nums = [3, 11, -2, 4] double_all(nums) what is the state table for the function doub le_all after the for loop has completed exactly 2 iterations (but before starting the third iterations)? Answer: (penalty regime: 0, 10, 20, ... %) Variable Value
Write a function round_numbers (floats) that returns a list of all the numbers in the list floats that are round numbers<br>(i.e. they represent integer values).<br>Hint: There are several ways to determine whether a float is a round number. Below are two options; you may choose<br>whichever one you like.<br>If num is a variable containing a floating-point number:<br>• num.is_integer() will return True if it is a round number and False otherwise. (Note that this uses a method of float;<br>we learned about methods in LM3.)<br>num == round (num) will be True if num represents an integer value and False otherwise.<br>For example:<br>Test<br>Result<br>numbers = [1.1, 5.0, 3.4, 2.6, 8.0, 9.5]<br>print (round_numbers(numbers))<br>[5.0, 8.0]<br>num<br>= [96.0, 60.8, 17.0, 69.5, 82.0, 77.2, 4.0, 33.9, 27.0]<br>[96.0, 17.0, 82.0, 4.0, 27.0]<br>print(round_numbers(nums))<br>

Extracted text: Write a function round_numbers (floats) that returns a list of all the numbers in the list floats that are round numbers (i.e. they represent integer values). Hint: There are several ways to determine whether a float is a round number. Below are two options; you may choose whichever one you like. If num is a variable containing a floating-point number: • num.is_integer() will return True if it is a round number and False otherwise. (Note that this uses a method of float; we learned about methods in LM3.) num == round (num) will be True if num represents an integer value and False otherwise. For example: Test Result numbers = [1.1, 5.0, 3.4, 2.6, 8.0, 9.5] print (round_numbers(numbers)) [5.0, 8.0] num = [96.0, 60.8, 17.0, 69.5, 82.0, 77.2, 4.0, 33.9, 27.0] [96.0, 17.0, 82.0, 4.0, 27.0] print(round_numbers(nums))

Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here