STATEMENTS:
Here is some actual historical weather data for the city of Toronto (at Pearson Airport): TorontoWeatherData.csv from January 1938 to December 2018, as downloaded from Environment Canada’s National Climate Data and Information Archive. It consists of 7 columns of numeric data:
• The year.
• The month in that year as a number between 1 and 12 inclusive.
• The mean temperature for that month.
• The maximum temperature for that month.
• The minimum temperature for that month.
• The total rainfall for that month in mm.
• The total snowfall for that month in cm.
You will see that the data is all mixed up! (How did that happen, I wonder…) Supplied code will create a list of dictionaries with a key in each dictionary for each of the 7 pieces of data, and one dictionary per month. You will need to carry out various searches and sorts on this data, starting by sorting it by date. Your sort function will be provided with the list of dictionaries (passed by reference) and the name of the key to sort by, as a string. As you will see when sorting by date it is easiest to use the key “yearmonth”. The functions you need to complete and the code you will use to test these functions is given here. Examine this starting program carefully to see how it works now and to determine what you need to do to finish it. A considerable amount of code is already supplied for you.
One function you need to complete saves the calculated yearly mean temperatures. You don’t have to, but if you did plot this data you would see:
It could be argued that the effects of global warming are evident!
While you cannot make wholesale changes to main, you can certainly comment out some function calls in order to test one function at a time as you develop them. The main function that you supply with your completed program should match the original main function supplied. Neither can you change the data file supplied above.
Since doc strings are supplied, your entire 20 marks will be devoted to the proper operation of the code you have to write. Submit your completed program only – no other files need to be uploaded.
粗糙的中文版:
以下是多伦多市(皮尔逊机场)的一些实际历史天气数据:1938年1月至2018年12月,下载自加拿大环境部的国家气候数据和信息档案。它由7列数字数据组成:
年度。
·当年的月份,介于1和12之间(含1和12)。
该月的平均温度。
该月的最高温度。
该月的最低温度。
该月的总降雨量(mm)。
当月总降雪量(cm)。
你会发现数据都混在一起了!(我想知道这是怎么回事…)提供的代码将创建一个字典列表,其中每个字典中都有7条数据的键,每个月一个字典。您需要对这些数据进行各种搜索和排序,从按日期排序开始。排序函数将以字符串形式提供字典列表(通过引用传递)和要排序的键的名称。正如您在按日期排序时看到的,最容易使用键“yearmonth”。此处给出了您需要完成的功能以及用于测试这些功能的代码。仔细检查这个启动程序,看看它现在如何工作,并确定完成它需要做什么。已经为您提供了大量的代码。
您需要完成的一个功能可以保存计算的年平均温度。您不必这样做,但如果绘制了这些数据,您将看到:
可以说,全球变暖的影响是显而易见的!
虽然您不能对main进行大规模更改,但是您当然可以注释掉一些函数调用,以便在开发它们时一次测试一个函数。完成的程序提供的主要功能应与提供的原始主要功能匹配。您也不能更改上面提供的数据文件。
由于提供了Doc字符串,因此您的整个20个标记将用于正确操作必须编写的代码。仅提交已完成的程序-不需要上载其他文件。