a. Write a function called daysOver that takes three arguments: a dictionary, a location (such as ‘Sydney’, ‘Adelaide’,etc) and a temperature and returns the number of days that were over the given temperature for the given location. For example, if we call the function using the line: total = daysOver(dictionaryData, ‘Adelaide’, 40) total will hold the number of days that Adelaide had a temperature greater than 40 celsius in the data. As a test, there were 54 days over 40 celsius in the data. Check that total is 54 for the example when you run your code. b. Use the daysOver function to print the number of days over 35 celsius for each of the following cities: 'Adelaide','Perth','Melbourne','Canberra','Sydney','Brisbane','Darwin' c. Which of the Australian cities has the most number of days over 35 celsius?
The programming language is - Python
a. Write a function called daysOver that takes three arguments: a dictionary, a location (such as ‘Sydney’, ‘Adelaide’,etc) and a temperature and returns the number of days that were over the given temperature for the given location. For example, if we call the function using the line:
total = daysOver(dictionaryData, ‘Adelaide’, 40)
total will hold the number of days that Adelaide had a temperature greater than 40 celsius in the data. As a test, there were 54 days over 40 celsius in the data. Check that total is 54 for the example when you run your code.
b. Use the daysOver function to print the number of days over 35 celsius for each of the following cities: 'Adelaide','Perth','Melbourne','Canberra','Sydney','Brisbane','Darwin'
c. Which of the Australian cities has the most number of days over 35 celsius?
My spreadsheet looks like this
Since I cannot attach an excel file, my excel file name is "weatherAUS.csv"
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
Hi there
Is it possible write the output of the function to a csv file? or point me towards a tutorial that covers this aspect.
Cheersb
Hi there.
Thank you for this response. Is it possible to then export the output to a csv file when say 40 is passed in as the temperature argument?
eg
City, Temp Count
Adelaide, 54
Perth, 28...
Im getting a Key Error in this code
Can someone confirm.