This sample program will ask the user to give a series of number and then our program will determine which of the given number is the highest and the lowest using Python as my programming language. The code is very simple and easy to understand. In order to stop running the program the user can simply type the keyword "ok".
If you have some questions please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Sample Program Output
Program Listing
lowest = None
highest = None
print("\n")
print("FIND THE HIGHEST AND LOWEST NUMBER IN PYTHON")
print '\n'
while True:
number = input('Please enter a number, or "ok" to stop: ' )
if number in ["OK", "ok"]:
break
try:
num = float(number)
if (lowest) is None or (num < lowest):
lowest = num
if (highest) is None or (num > highest):
highest = num
except ValueError:
print("Non numeric data was entered.")
except:
print("Error with input...")
print '\n'
print 'The Highest Number is ' ,highest,'.'
print 'The Lowest Number is ' , lowest,'.'
print '\n'
print("END OF PROGRAM")