Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Purpose: To practice creating and manipulating lists with list comprehensions. Degree of Difficulty: Mostly Easy Lets look at some weather data from January 2023, which

Purpose: To practice creating and manipulating lists with list comprehensions. Degree of Difficulty: Mostly Easy Lets look at some weather data from January 2023, which properly represented a Saskatchewan winter. In a5q2v1_starter.py you are given a definition of a list of lists. Each sublist contains three pieces of infor- mation the date, the day daily high temperature, daily low temperature. Create the following list comprehensions:. (a) Are there any days where the temperature was above 0? Use a single list comprehension to create a list of the dates where the daily high temperature was more than 0 and print() the results. (b) You probably would agree that Monday is the worst day to be cold. Use a single list comprehension to create a list of the daily low temperatures for Mondays and print() the results. (c) Some days start cold but get much warmer. Use a single list comprehension to create a list of the difference between the daily low and daily high temperature for each date and print() the results. (d) But what about the weekends!? Use a single list comprehension to create a list of lists where each sub- list consists of a date and daily high temperature, but only include dates that are Saturday or Sunday and print() the results. Note that this question is to test your use of list comprehensions. No marks will be given for solutions that do not use list comprehensions. Please be sure to use print() to show your results in the console.

weather_yxe_2023 = [ ["2023-01-01", "Sunday", - 8.1, - 24.6], ["2023-01-02", "Monday", - 8, - 19], ["2023-01-03", "Tuesday", - 5.1, - 17.6], ["2023-01-04", "Wednesday", - 9.9, - 20.1], ["2023-01-05", "Thursday", - 13.6, - 22.1], ["2023-01-06", "Friday", - 12.3, - 17.1], ["2023-01-07", "Saturday", - 10.2, - 17.9], ["2023-01-08", "Sunday", - 8.5, - 17.9], ["2023-01-09", "Monday", - 11.8, - 20.4], ["2023-01-10", "Tuesday", - 10, - 18.5], ["2023-01-11", "Wednesday", - 8.4, - 12], ["2023-01-12", "Thursday", - 9.8, - 16.7], ["2023-01-13", "Friday", - 12, - 18], ["2023-01-14", "Saturday", - 8, - 14.6], ["2023-01-15", "Sunday", - 7.7, - 9.6], ["2023-01-16", "Monday", - 6.5, - 9], ["2023-01-17", "Tuesday", - 9, - 11.3], ["2023-01-18", "Wednesday", - 5.6, - 10.2], ["2023-01-19", "Thursday", - 4.3, - 9.3], ["2023-01-20", "Friday", - 6.5, - 16.4], ["2023-01-21", "Saturday", - 3.7, - 15.7], ["2023-01-22", "Sunday", 1.3, - 9.2], ["2023-01-23", "Monday", - 1.1, - 16.3], ["2023-01-24", "Tuesday", - 6.2, - 12.2], ["2023-01-25", "Wednesday", - 2.6, - 6.4], ["2023-01-26", "Thursday", 3.7, - 6.8], ["2023-01-27", "Friday", - 4.2, - 23.4], ["2023-01-28", "Saturday", - 18, - 26.7], ["2023-01-29", "Sunday", - 18.6, - 28.9], ["2023-01-30", "Monday", - 19, - 29.6], ["2023-01-31", "Tuesday", - 16.3, - 25.4]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions

Question

1. How will you, as city manager, handle these requests?

Answered: 1 week ago

Question

1. Identify the sources for this conflict.

Answered: 1 week ago