Using the given clamp function, write a function clamp_all that takes a list of integers along with two bounds low and high and and MODIFIES the list so that each number is replaced by the result of calling clamp on that number with the two given bounds. For example, if you run the code,

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Python
1 import foo
3 # Write your clamp_all function here.
4 # ALREADY IMPLEMENTED IN THE foo MODULE IMPORTED ABOVE
DO NOT WRITE clamp AGAIN, USE THE ONE
6.
7
8 #Do not modify the following lines of code
'_main__' :
9 if _name__ ==
1st = [12, -7, 16, 25, 99]
clamp_all(lst, 10, 20)
print(lst)
1st = [12, -7, 16, 25, 99]
clamp_all(lst, 40, 10)
print(lst)
1st = [24, 8, 16, 34, 9]
clamp_all(lst, 40, 10)
print(lst)
10
11
12
13
14
15
16
17
18
Transcribed Image Text:1 import foo 3 # Write your clamp_all function here. 4 # ALREADY IMPLEMENTED IN THE foo MODULE IMPORTED ABOVE DO NOT WRITE clamp AGAIN, USE THE ONE 6. 7 8 #Do not modify the following lines of code '_main__' : 9 if _name__ == 1st = [12, -7, 16, 25, 99] clamp_all(lst, 10, 20) print(lst) 1st = [12, -7, 16, 25, 99] clamp_all(lst, 40, 10) print(lst) 1st = [24, 8, 16, 34, 9] clamp_all(lst, 40, 10) print(lst) 10 11 12 13 14 15 16 17 18
In this problem, you have available to you a working version of the function clamp described in part (a). It is located in a module named
foo.
Using the given clamp function, write a function clamp all that takes a list of integers along with two bounds low and high and and
MODIFIES the list so that each number is replaced by the result of calling clamp on that number with the two given bounds.
For example, if you run the code,
1st = [12, -7, 16, 25, 99]
clamp_all (1st, 10, 20)
print (lst)
the list would then contain the values [12, 10, 16, 20, 20]
Do not re-implement the clamp function, just import the foo module and use it.
Transcribed Image Text:In this problem, you have available to you a working version of the function clamp described in part (a). It is located in a module named foo. Using the given clamp function, write a function clamp all that takes a list of integers along with two bounds low and high and and MODIFIES the list so that each number is replaced by the result of calling clamp on that number with the two given bounds. For example, if you run the code, 1st = [12, -7, 16, 25, 99] clamp_all (1st, 10, 20) print (lst) the list would then contain the values [12, 10, 16, 20, 20] Do not re-implement the clamp function, just import the foo module and use it.
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY