# this program will calculate the third side by using phythegrasos theorm:
import math # this is necessary for the formula particularly sqr
sideA = input("Please enter side A: ")
sideB = input("Please enter side B: ")
sideC = input("Please enter side C: ")
# to find which side is empty use if statement and to refer to empty in coding is ''
if sideA == '':
sideB = float(sideB)
sideC = float(sideC)
sideA = math.sqrt(sideC**2 - sideB**2)
print(f"Given side C = {sideC} and side B = {sideB}")
print(f"Calculated Side A as {round(sideA,4)}")
elif sideB == '':
sideA = float(sideA)
sideC = float(sideC)
sideB = math.sqrt(sideC**2 - sideA**2)
print(f"Given side C = {sideC} and side A = {sideA}")
print(f"Calculated Side B as {round(sideB,4)}")
else:
sideA = float(sideA)
sideB = float(sideB)
sideC = math.sqrt(sideA**2 + sideB**2)
print(f"Given side A = {sideA} and side B = {sideB}")
print(f"Calculated Side C as {round(sideC,4)}")
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter