Lowest price ever! Learn Generative AI for 48% less!
Get my discount0
When writing a code in python always take proper care of idendation
And here u made mistakes in the condition checking and took string input() for height
weight = int(input())
height = int(inptut())
X = weight/height*2
if x < 18.5 :
print (" underweight")
elif x > 18.5 and x < 25:
print ("normal")
elif x > 25 and x < 30:
print ("overweight")
elif x > 30
print (" obesity")
since your are checking x with a floating point value u can also get input as
weight = float(input())
height = float(input())
0
That is the right code ???
0
weight = int(input())
height = float(input())
x = weight/height**2
if x < 18.5 :
print ("Underweight")
elif 18.5 <= x < 25:
print ("Normal")
elif 25 <= x < 30:
print ("Overweight")
elif 30 <= x:
print ("Obesity")
0
weight = int(input())
height = float(input())
x = weight/height**2
if x < 18.5 :
print ("Underweight")
elif 18.5 <= x < 25:
print ("Normal")
elif 25 <= x < 30:
print ("Overweight")
elif 30 <= x:
print ("Obesity")
I am try this code but not working
0
Try this it will be of great help
#Do well to observe all these steps next time as they are vital
weight = float(input("Enter your weight: "))
height=float(input("Enter your height: "))
x= weight/(height*2)
if x<18.5:
print ( f" your weight is {x} ,and you are underweight")
elif 18.5< x<25:
print (f"You are normal,your weight is {x}")
elif 25<=x<30:
print (f"You are overweight, your weight is {x}")
elif x>=30:
print (f"You are obese, your weight is {x}. You do need to slim down")
0
Try again
0
Be careful with the indentation, the spelling and the syntax
Indentation - all commands that relate to the if, else, elif statements must be indented or else the code won't know where the if condition ends
Spelling- input not inptut
Syntax - elif statements must end with a colon(:) - your first does, next two dont.
Hope these tips help!
0
Abhishek Dey Your question appears to a duplicate please use the searchbar before asking.
Please use the forum guidelines provided below and use the 8 rules for getting help from the community.
https://www.sololearn.com/Blog/38/8-simple-rules-to-get-help-from-the-community
Your question will be marked for deletion.
Reason duplicate threads are removed to:
Focus substantially similar discussion in one thread and to prevent forums being cluttered with multiple threads on the same topic.
https://www.sololearn.com/Discuss/1316935/?ref=app
https://www.sololearn.com/discuss/2687547/?ref=app
https://www.sololearn.com/discuss/2748154/?ref=app
https://www.sololearn.com/discuss/2686011/?ref=app
https://www.sololearn.com/discuss/2750158/?ref=app
https://www.sololearn.com/discuss/2686226/?ref=app
https://www.sololearn.com/discuss/2771623/?ref=app