Hello, I am new to python but I don’t understand why POUNDS in undefined. Everything seems to add up. I am new to python and am learning for school, sorry if this is a stupid question. also can someone tell me how the round up command works? couldn’t seem to figure that one out.
#BMI calaculator
#input
def whatis():
POUNDS = float(input("How much do you Weight in pounds? : "))
inches = float(input("How tall are you inches? : "))
whatis()
#processing
Numerator = (POUNDS * 703)
Denominator = (inches * inches)
BMI = (Numerator / Denominator )
#output
round(float (BMI, 1))
print ('Your BMI is : ', BMI)
If you assign to a variable in a function, that variable is considered to be local to the function unless you declare, in the function, that it’s global.
You do that with the global statement:
def whatis():
global POUNDS, inches
POUNDS = float(input("How much do you Weight in pounds? : "))
inches = float(input("How tall are you inches? : "))