I am trying to make a measurement machine with python, but when I enter the measurements it just goes on with the code, I want it to stop processing once I get a result, here is the code I have done so far:
I need it to stop after "print math.sqrt(int(h1)**2 + int(h2)**2)
"
need = raw_input("What do you need to Use?")
if need == "pythagoras" or "Pythagoras":
pythagoras = raw_input("What side do you Need?")
if pythagoras == "hypotenuse" or "Hypotenuse":
h1 = int(raw_input("Known Side 1"))
h2 = int(raw_input("Known Side 2"))
import math
print math.sqrt(int(h1)**2 + int(h2)**2)
Calling sys.exit
will immediately terminate the execution of the program, like return
does for functions:
import sys
...
print math.sqrt(int(h1)**2 + int(h2)**2)
sys.exit()