-2

This is my code

weight = float(input("Please Enter Your Weight In KIlograms: "))
height = float(input("Please Enter Your Height In Meters: "))

result = weight / height ** height
print("Your BMI is " + result)

And this is the error:

OverflowError: (34, 'Result too large')

I'm really not to familiar with the technical terms yet, so you might have to be a little more specific in your explanation.

desertnaut
  • 57,590
  • 26
  • 140
  • 166

2 Answers2

0

Try something like this

height = float(input("Input your height in meters: "))
weight = float(input("Input your weight in kilogram: "))
print("Your body mass index is: ", round(weight / (height * height), 2))
Jean Camargo
  • 340
  • 3
  • 17
0

your code needs some changes. Your final print statement tries concatenate a string and a float ie the string being "Your BMI is " the float being result. So you have to make them both the same type as below. ("Your BMI is " + str(result)). And also the BMI equation is Weight/Height^2 rather than Weight/ Height^Height. So change the calculation part to result = weight / height ** 2.

weight = float(input("Please Enter Your Weight In Kilograms: ")) 
height = float(input("Please Enter Your Height In Meters: "))

result = weight / height ** 2 
print("Your BMI is " + str(result))
Tomerikoo
  • 18,379
  • 16
  • 47
  • 61