# QUADRILATERALS # Frans Coenen # University of Liverpool # 15 March 2013 # Function to input an angle. Checks that angle is less than 180 degrees, # if so function returns the angle, otherwise it repeats! def inputAngle() : MIN_ANGLE = 0 MAX_ANGLE = 180 print('Input angle in degrees (range {0} to {1}):'.format(MIN_ANGLE,MAX_ANGLE)) angle = int(input()) if angle>MIN_ANGLE and angle=360 : print('ERROR 1: First three angles ({0}, {1} and {2})'.format(angleA,angleB,angleC)) print('add up to {0} which is greater than 360'.format(total)) isQuadrilateral = False # Otherwise calculate fourth angle else : angleD = 360-total; # Check angle D if (angleD < 180) : print('angleA = {0}, angleB = {1},'.format(angleA,angleB)) print('angleC = {0}, angleD = {1}'.format(angleC,angleD)) else : print('ERROR 2: angle D = {0} is greater than 180 degrees'.format(angleD)) isQuadrilateral = False # Return return isQuadrilateral # Function to determine the nature of the quadrialteral --- squareOrRectangle, kite, # parallelogram, or some other qudrilateral. def idQuadType() : if angleA == angleC : if angleB == angleD : if angleA == angleB : print('Shape is a square or a rectangle') else : print('Shape is a parallelogram') else : print('angleA = {0}, angleB = {1},'.format(angleA,angleB)) print('angleC = {0}, angleD = {1}'.format(angleC,angleD)) print('Shape is a Kite 1') else : if angleB == angleD : print('Shape is a Kite 2') else : print('Shape is some other Quadrialeteral') # Input first three angles print('Angle A') angleA = inputAngle() print('Angle B') angleB = inputAngle() print('Angle C') angleC = inputAngle() # Main if (isaTrueQuadrilateral()) : angleD = 360-(angleA+angleB+angleC) idQuadType()