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 Submitty Course Resources page as lec24_ex_files.zip. Each problem requires that you write / modify exactly one line of code!

  1. Modify the code in prob1.py to generate a new list where all values are replaced by their absolute values. You must use map, but there is no need for a lambda function.

  2. Modify the code in prob2.py to 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 use map, filter and min. 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.

  3. Modify the code in prob3.py to 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 a lambda function.

  4. Modify the code in prob4.py to 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!!