A meteorological company wants you to write a simple program that stores the high temperatures and low temperates for each of the months of the year. After consulting with trusted programming partners, you come up with a great idea. It is as follows:
- create an array called month that lists all twelve month names as strings
- create another array called highs that initializes 12 element members to 0.
- create another array called lows that also initializes 12 element members to 0.
- prompt the user to enter the high temperature and low temperature for each month.
- create a module called findHighest, that searches the highs array for the highest temperature.
- create a module called findLowest that searches the lows array for the lowest temperature.
- output which month was the hottest month and which month was the coldest month.
The main module looks like this minus a few adjustments. Use the answer text area to write-in the code to complete the main definition and then define the methods findHighest and findLowest.
def main():
month = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}
highs = #create an array of 12 elements initialized to 0
lows = #create an array of 12 elements initialized to 0
for temps in range (len(months)):
highs[temps] = int(input("Enter the highest temperature for " + month[temps] + ": "))
lows[temps] = int(input("Enter the lowest temperature for " + month[temps] + ": "))
highMonth = #the module call to find the position of the highest month
lowMonth = #the module call to find the position of the lowest month
print("The hottest month was ", month[highMonth], " at ", highs[highMonth], " degrees")
print("The coldest month was ", month[lowMonth], " at ", lows[lowMonth], " degrees")
def findHighest(arr):
'''define how to find the highest value in an array and return the position of that highest value'''
def findLowest(arr):
'''define how to find the lowest value in an array and return the position of that lowest value '''