def main():
highTemps = [-3, -2, 3, 11, 19, 23, 26, 25, 20, 13, 6, 0]
lowTemps = [-11, -10, -5, 1, 8, 13, 16, 15, 11, 5, -1, -7]
weatherDB = createDB(highTemps, lowTemps)
for m in weatherDB:
for t in weatherDB[m]:
print(m, t, weatherDB[m][t])
m = input("Enter a Month Name: ")
if m in weatherDB:
print(weatherDB[m])
else:
print("Month not found")
def tempByMonth(weatherDB, month):
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"]
weatherDB = {}
for i in range(len(months)):
month = months[i]
weatherDB[month]
return weatherDB
def averageHighTemps(weatherDB):
#Here is the function
return
#DO NOT change this function:
def createDB(highTemps, lowTemps):
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"]
weatherDB = {}
for i in range(len(months)):
month = months[i]
weatherDB[month]={"high":highTemps[i],"low":lowTemps[i]}
return weatherDB
main()
How can I have the averageHighTemps function to take the weather database as an argument, and returns the average of the monthly high temperatures. This code should only be in the function of averageHighTemps.
question from:
https://stackoverflow.com/questions/65833487/how-can-i-have-the-averagehightemps-function-to-take-the-weather-database-as-an