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 double_all after the for loop has completed exactly 2 iterations (but before starting the third iterations)? Answer: (penalty regime: 0, 10, 20, ... %) Variable Value

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%
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
Transcribed Image 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
(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))
Transcribed Image 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))
Expert Solution
steps

Step by step

Solved in 5 steps with 2 images

Blurred answer
Knowledge Booster
Linked List Representation
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education