Lecture 24 — Exercises¶
Solutions to the problems below must be sent to Submitty for automatic scoring. A separate file must submitted for each problem. Start with the files available on the Piazza resource page as lec24_ex_files.zip. Solutions must be submitted by 4 pm on Friday, April 28. 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,filterandmin. 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. The sort should be from greatest distance to least distance. - 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!!