Exit skills:
Explain the difference between two or more algorithms
Explain advantages and disadvantages of algorithms
Develop and explain an algorithm to address a specific problem
Problem
Suppose a programmer wants to develop a program that records temperatures for four cities. The program should ask for each city name, and highest and lowest temperature for a particular year. Three arrays will be used to store the city names, the low temperatures, and the high temperatures. After storing all the data, the program should display a list of cities with high temperatures above the average high, and a list of cities with low temperatures below the average low. The solution to this problem follows.
Mat's pseodocode tool and Mr Mulkey's pseudocode tool
Convert this program to a Python 3 version!
//p219 Ex24
//A program that outputs the cities with temperatures above the average of high temperatures and cities below the average of low temperatures
TOTALH = 0 //Variable declaration and initialisation (total high)
TOTALL = 0 //Variable declaration and initialisation (total low)
AVGH = 0 //Variable declaration and initialisation (average of high)
AVGL = 0 //Variable declaration and initialisation (average of low)
CITYNAMES = new Array() //Declaration of array that will hold the names
HIGHTEMP = new Array() //Declaration of array for high temperatures
LOWTEMP = new Array() //Declaration of array for low temperatures
output "Hello"
loop I from 0 to 3
CITYNAMES[I] = input("Type the name of the city")
HIGHTEMP[I] = input("Type the Maximum temperature of the city")
LOWTEMP[I] = input("Type the Minimum temperature of the city")
TOTALH = TOTALH + HIGHTEMP[I]
TOTALL = TOTALL + LOWTEMP[I]
end loop
AVGH = TOTALH/4
AVGL = TOTALL/4
output "Cities above Average High:"
loop I from 0 to 3
if HIGHTEMP[I] > AVGH then
output CITYNAMES[I], "+"
end if
end loop
output "Cities below Average Low:"
loop I from 0 to 3
if LOWTEMP[I] < AVGL then
output CITYNAMES[I], "+"
end if
end loop