# Help with pythagoras calculator (python)

hello, i need help for an assignement with a pythagoras calculator in python, the code i have made does not work and returns a syntax error in line 15 (print function), any help is greatly appreciated.

``````def side(a,h):
return (h**2 - a**2)**0.5

def hyp(a,b):
return (a**2 + b**2)**0.5
``````

This gives us two pure functions that stand alone.

``````def side_side():
side_a = input("Enter Side A:")
side_b = input("Enter Side B:")
return "      Side C: %.4f" % hyp(side_a, side_b)

def side_hyp():
side_a = input("Enter Side A:")
side_c = input("Enter Side C:")
return "      Side B: %.4f" % side(side_a, side_c)

def bye():
return "Bye!"

def select():
return int(input("Enter a number from the menu..."))
``````

These are the control and module functions. Now all we need is a switch to activate them.

``````switch = {
0: bye,
1: side_side,
2: side_hyp
}

What would you like to calculate?
0. Exit
1. Hypotenuse
2. Other side
"""

print(switch[select()]())
``````

Test run:

``````What would you like to calculate?
0. Exit
1. Hypotenuse
2. Other side

Enter a number from the menu... 1
Enter Side A: 4
Enter Side B: 3
Side C: 5

What would you like to calculate?
0. Exit
1. Hypotenuse
2. Other side

Enter a number from the menu... 2
Enter Side A: 4
Enter Side C: 5
Side B: 3

What would you like to calculate?
0. Exit
1. Hypotenuse
2. Other side

Enter a number from the menu... 0
Bye!
``````
Code
``````def side(a,h):
return (h**2 - a**2)**0.5

def hyp(a,b):
return (a**2 + b**2)**0.5

def side_side():
side_a = float(input("Enter Side A:"))
side_b = float(input("Enter Side B:"))
return "      Side C: %d" % hyp(side_a, side_b)

def side_hyp():
side_a = float(input("Enter Side A:"))
side_c = float(input("Enter Side C:"))
return "      Side B: %d" % side(side_a, side_c)

def bye():
return "Bye!"

def select():
return int(input("Enter a number from the menu..."))

switch = {
0: bye,
1: side_side,
2: side_hyp
}