Lecture 24 — Exercises¶
Solutions to the problems below must be sent to Submitty for
automatic scoring. A separate file must be submitted for each problem.
Start with the files available from the Course Materials section on Submitty as
lecture24_files.zip. Each problem requires that you write / modify exactly one
line of code!
Modify the code in
prob1.pyto generate a new list where all values are replaced by their absolute values. You must usemap(), but there is no need for a lambda function.Modify the code in
prob2.pyto determine the minimum x value of all points that are in the first quadrant (x and y values both positive). This will require you to usemap(),filter(), andmin(). You can write this in a single line, but for clarity you are welcome to write it on two or three. Do not create a new list.Modify the code in
prob3.pyto sort the points in a list by their distance from the origin (i.e., by the magnitude of the points). This will require use of alambdafunction.Modify the code in
prob4.pyto use a list comprehension statement to convert a list of Fahrenheit temperatures to Celsius, while eliminating those that are below freezing.
Congratulations: You are finished with the CS 1 lecture exercises!!