Just trying some code out:
a_leg = 5
b_leg = 5
hyp = (a_leg**2)(b_leg**2)
print(hyp)
I get the below error:
hyp = (a_leg**2)(b_leg**2)
TypeError: 'int' object is not callable
What does this mean? I know it is very basic but will appreciate your help.
Thanks
You are getting this because of
hyp = (a_leg**2)(b_leg**2)
In programming languages you have to explicitly use operators. In this case, the correct code would be:
hyp = (a_leg**2)*(b_leg**2)
notice the *
between those two brackets.
You are getting this error because:
(a_leg**2)
returns an integer that is not callable. You can make a function to calculate the hypotenuse like these:
from math import sqrt
a_leg = 5
b_leg = 5
def hyp(a, b):
h = sqrt((a**2) + (b**2))
return h
print(hyp(a_leg, b_leg))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.