Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Starter code: # Historical Weather for February 2018 in Saskatoon # Daily Data is in the Format [date, day, high, low] weather_yxe_2018 = [ [2018-02-01,Thursday,-18.6,-30.6,],
Starter code:
# Historical Weather for February 2018 in Saskatoon # Daily Data is in the Format [date, day, high, low] weather_yxe_2018 = [ ["2018-02-01","Thursday",-18.6,-30.6,], ["2018-02-02","Friday",-19.6,-23.4,], ["2018-02-03","Saturday",-22.3,-30.4,], ["2018-02-04","Sunday",-17.4,-27.7,], ["2018-02-05","Monday",-16.2,-25.3,], ["2018-02-06","Tuesday",-16.6,-27.8,], ["2018-02-07","Wednesday",-18.2,-30.5,], ["2018-02-08","Thursday",-18.1,-29.5,], ["2018-02-09","Friday",-15.5,-29.8,], ["2018-02-10","Saturday",-9.4,-19.6,], ["2018-02-11","Sunday",-19.2,-31.2,], ["2018-02-12","Monday",-14.5,-32.4,], ["2018-02-13","Tuesday",2.3,-17.4,], ["2018-02-14","Wednesday",0.1,-19.9,], ["2018-02-15","Thursday",-14.3,-32,], ["2018-02-16","Friday",-7.5,-21.2,], ["2018-02-17","Saturday",-11,-19.6,], ["2018-02-18","Sunday",-14.2,-25.9,], ["2018-02-19","Monday",-15.3,-30.2,], ["2018-02-20","Tuesday",-13.7,-28.6,], ["2018-02-21","Wednesday",-12.3,-31.3,], ["2018-02-22","Thursday",-8.1,-25.3,], ["2018-02-23","Friday",-6.2,-21.5,], ["2018-02-24","Saturday",-2,-14.1,], ["2018-02-25","Sunday",-3.7,-15.4,], ["2018-02-26","Monday",-5.2,-19.3,], ["2018-02-27","Tuesday",-4.4,-13.9,], ["2018-02-28","Wednesday",-0.3,-16.6,] ] # Write your list comprehensions below! # Part A) - Are any days above 0? # Part B) - Monday low temperatures? # Part C) - Temperature differences? # Part D) - Weekend Highs?Purpose: To practice creating and manipulating lists with list comprehensions. Degree of Difficulty: Mostly Easy Some people hate February because it's so cold! In order to prepare ourselves for the month, let's look back at some historical weather data from 2018. Maybe it wasn't as bad as we remember? In a4q2 starter.py you are given a definition of a listof lists. Each sublist contains four pieces of information the date. day of the week, daily high temperature, daily low temperature. Create the following list comprehensions. (a) Are any days above O? Use a single list comprehension to create a list of the dates where the daily high temperature was more than O and print ) the results. (b) Mondays are the worst. Use a single list comprehension to create a list of the daily low temparatures for days that are Monday and printO 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 weekend!? 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. What to Hand In Rename your completed a4q2-starter.py file to a4q2.py and submit it. Evaluation . 1 mark each for parts (a). .b), and (cl. 2 marks for part (d)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started