lecture #7
##Example of Structured code
##
##import math
### Get Base
##inputOK = False;
##while not inputOK:
## base = input('enter Base: ')
## if type(base)==type(1.0): inputOK=True
## else: print('Error: You must enter a float value');
##
### Get height
##inputOK = False;
##while not inputOK:
## height = input('enter Height: ')
## if type(height)==type(1.0): inputOK=True
## else: print('Error: You must enter a float value');
##
##
##hyp = math.sqrt(base*base+height*height)
##
##print 'Base '+str(base)+'Height:'+str(height)+'hyp:'+str(hyp)
##
##
import math
def getFloat(reqMsg,ErrMsg):
inputOK = False;
while not inputOK:
val = input(reqMsg)
if type(val)==type(1.0): inputOK=True
else: print(errMsg);
return val
base = getFloat('Enter Base:','Err: Base must be float value.')
height = getFloat('Enter Height:','Err:Height Must be float value.')
hyp = math.sqrt(base*base+height*height)
print 'Base '+str(base)+'Height:'+str(height)+'hyp:'+str(hyp)