#Name: Calum Macleod
#Date : November 6, 2012
#Purpose: A Python program with a loop that lets the user enter a series of whole numbers.
#The user should enter the number -99 to signal the end of series.
#After all the numbers have been entered,
#the program should display the largest and smallest numbers entered.
#The program should re-run as long as the user wants to work with another
#set of numbers.
import math
#Real number, square
#Real constant STOP = -99
STOP = -99
print( '''
------------------------------------------------------------------------------
Accept a number from the user and display the number and its square.
The program executes till the user enters -99.
Non-numberic input will be handled and an appropriate error message displayed.
Program will terminate when a non-numeric input is entered
------------------------------------------------------------------------------
''')
number = 1
while (number !=STOP):
try:
number = float(input("Please enter a number, %d to stop: " %STOP ))
if (number != STOP):
square = math.pow(number, 2)
except ValueError:
number = 1
print("Non numberic data was entered.")
except:
print("Error with input...")
else:
if (number != STOP):
square = math.pow (number, 2)
print("The square of %.2f is %.2f." %(number,square))
print("Program terminating...")
I was wondering how i would get the largest and smallest number from any number that the user enters. Im about 4 weeks into my program but my teacher doesn't do a very well at explaining what to do.