# 1st input: enter height in meters e.g: 1.65height = input()# 2nd input: enter weight in kilograms e.g: 72weight = input()# 🚨 Don't change the code above 👆# Write your code below this line 👇height = float(height)weight = float(weight)weight = weight ** 2 bmi = int(height / (weight))print(bmi)
Question
1st input: enter height in meters e.g: 1.65height = input()# 2nd input: enter weight in kilograms e.g: 72weight = input()# 🚨 Don't change the code above 👆# Write your code below this line 👇height = float(height)weight = float(weight)weight = weight ** 2 bmi = int(height / (weight))print(bmi)
🧐 Not the exact question you are looking for?Go ask a question
Solution
The code you've written is intended to calculate the Body Mass Index (BMI) of a person. However, there's a mistake in the formula. The correct formula for BMI is weight (kg) divided by height (m) squared. Here's the corrected code:
# 1st input: enter height in meters e.g: 1.65
height = input()
# 2nd input: enter weight in kilograms e.g: 72
weight = input()
# Convert the inputs to float
height = float(height)
weight = float(weight)
# Calculate BMI
bmi = weight / (height ** 2)
# Print the result
print(bmi)
This code will correctly calculate the BMI. It first takes the height and weight as inputs, converts them to floats, calculates the BMI by dividing the weight by the square of the height, and then prints the result.
Similar Questions
0/0
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.