I am really new to python and just tried to make this Pythagorean theorem calculator for the sake of it and it works except for when I try and calculate b. I know having b isn’t necessary but I don’t know why the or doesn’t work. Please let me know how to fix this.
Thanks!
import time
import math
def repeat():
print ("Welcome to the pythagoras calculator!")
time.sleep(1.5)
calculation = input ("Do you want to find a, b or c?\na/b/c\n")
if calculation == ("a" or "b"):
if calculation == "a":
b = int(input ("What is b?"))
elif calculation == "b":
a = int(input ("What is a?"))
c = int(input ("What is c?"))
if calculation == "a":
a = (math.sqrt(c**2 - b**2))
print ("a is ", a, ". Thank you for using my calculator!")
elif calculation == "b:":
b = (math.sqrt(c**2 - a**2))
print ("b is ", b, ". Thank you for using my calculator!")
elif calculation == "c":
a = int(input ("What is a?"))
b = int(input ("What is b?"))
c = (math.sqrt(a**2 + b**2))
print ("c is ", c, ". Thank you for using my calculator!")
else:
print ("Please enter a valid letter next time")
while True:
time.sleep(1)
repeat()