#THIS PROGRAM IS A TRIGONOMETRY CALCULATOR, AND WILL LATER BE TURNED INTO A CLASS #THIS PROGRAM WILL BE ABLE TO : # * CALCULATE PERIMETER & AREA OF TRIANGLES # * PLUG NUMBERS INTO THE PYTHAGOREAN THEORM # * DETERMINE REFERENCE ANGLES # * CALCULATE ANGLE OF ELEVATION & DEPRESSION # * CALCULATE UNIQUE IDENTITIES import math leg1 = input("ENTER THE LEG OF THE TRIANGLE: ") nextVal = input("\nPRESS 1. IF THE NEXT VALUE IS THE HYP\nPRESS 2. IF THE NEXT VALUE IS ANOTHER LEG\n") if nextVal == 1: hyp = input("ENTER THE HYP: ") hyp = hyp ** 2 leg1 = leg1 ** 2 leg2 = hyp - leg1 leg2 = math.sqrt(leg2) leg1 = math.sqrt(leg1) hyp = math.sqrt(hyp) elif nextVal == 2: leg2 = input("\nENTER THE OTHER LEG: ") leg2 = leg2 ** 2 leg1 = leg1 ** 2 hyp = leg1 + leg2 hyp = math.sqrt(hyp) leg1 = math.sqrt(leg1) leg2 = math.sqrt(leg2) print("\nLEG1 = %.3f\nLEG2 = %.3f\nHYP = %.3f") % (leg1,leg2,hyp) ans = input("PRESS 1. TO FIND THE PERIMETER\nPRESS 2. FIND THE AREA ") if ans == 1: base = input("ENTER THE BASE") height = input("\nENTER THE HEIGHT") print("\nBASE = %2f, HEIGHT = %.2f") % (base,height) perimeter = .5 * (base * height) print("PERIMETER = %.2f") % (perimeter) elif ans == 2: area = leg1 + leg2 + hyp print("AREA = %.2f") % (area) ans = input("\nPRESS 1. TO FIND THE REFERENCE ANGLE\nPRESS 2. TO FIND UNIQUE IDENTITIES\n") if ans == 1: numType = input("PRESS 1. FOR RADIANS\nPRESS 2. FOR DEGREES") if numType == 1: theirRadians = input("\nENTER YOUR ANGLE IN RADIANS ") elif numType == 2: theirDegrees = input("\nENTER YOUR ANGLE IN DEGREES ") while theirDegrees > 360: theirDegrees = theirDegrees - 360 if theirDegrees == 90 or theirDegrees == 180 or theirDegrees == 270 or theirDegrees == 360: print'''THE ENTER VALUE %d IS A QUADRANTEL ANGLE''' % (theirDegrees) elif theirDegrees < 90: refAng = theirDegrees elif theirDegrees > 90 and theirDegrees < 180: refAng = 180 - theirDegrees elif theirDegrees > 180 and theirDegrees < 270: refAng = theirDegrees - 180 else: refAng = 360 - theirDegrees print("\nTHE REFERENCE ANGLE: %d") % (refAng) elif ans == 2: print'''NEXT LINE OF LOGIC''' print"\nSTAY TUNED FOR MORE!!!"
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question