Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Predefined List
- Weather = ['Monday 42', 'Tuesday 45', 'Wednesday 86', 'Thursdays 75', 'Friday 43', 'Saturday 73', 'Sunday 29']
- #Calculation functions
- def CalcLow(List):
- CrntLowTemp = int(List[0].split()[1])
- for temps in List:
- Working = int(temps.split()[1])
- if Working < CrntLowTemp:
- CrntLowTemp = Working
- return CrntLowTemp
- def CalcHigh(List):
- CrntHighTemp = int(List[0].split()[1])
- for temps in List:
- Working = int(temps.split()[1])
- if Working > CrntHighTemp:
- CrntHighTemp = Working
- return CrntHighTemp
- def CalcAverage(List):
- AVG = 0
- for temps in List:
- AVG += int(temps.split()[1])
- return AVG / len(List)
- #Print functions
- def PrintWeather(List):
- for element in List:
- Parts = element.split()
- print(Parts[0] + '\n' + Parts[1] + '\n')
- def PrintHigh(List):
- print('The High is\n' + str(CalcHigh(List)) + '\n')
- def PrintLow(List):
- print('The Low is\n' + str(CalcLow(List)) + '\n')
- def PrintAverage(List):
- print('The Average is\n' + '{0:.2f}'.format(CalcAverage(List)) + '\n')
- #Output
- PrintWeather(Weather)
- PrintLow(Weather)
- PrintHigh(Weather)
- PrintAverage(Weather)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement