+ 3
BMI Calculator
I input: weight = input() height = input() x = (weight/height/height) if(x < 18.5): print("Underweight") if(x >= 18.5 and x < 25): print("Normal") if(x >= 25 and x < 30): print("Overweight") if(x > 30): print("Obesity") It outputs: Trace back (most recent call last) File “/usercode/file0.py”,in <module> x = (weight/height/height) TypeError: unsupported operand type(s) for ** or pow() : ‘str’ and ‘int’
24 Answers
+ 7
It's because something is wrong. If you need help on finding out what, pls edit your question with:
1. The error
2. A tag with the language
+ 4
Jibran Khan sᴜᴊᴀɴ.ᴇ.s. Pls avoid answering with finished code. Remember this is a learning app. We have to help others to know how to solve problems - if we solve for them, there's no learning.
Prefer giving hints the OP can follow and find the solution.
+ 3
You are trying to split string variables that need to be converted to numeric variables.
+ 2
Make it x = (weight/height**2) not (weight/height/height).
+ 1
What do you mean
+ 1
Data entry is in the form of a string even when you enter numbers.
+ 1
So you mean to convert the input to a float
+ 1
Yes
+ 1
You have all the conditions nested in one if(x< 18.5)
+ 1
I made the code and itt is write cuz of ur help thank you very much
+ 1
Happy coding!
+ 1
Change your height to float:
Height = float()
+ 1
Nícolas Nascimento Good. Just check the lesson or docs for 'input' function and review the arguments you passed to it in your code.
0
😳 What exactly do you not understand in my answer?
0
What is meant by numeric variables
0
😳 you surprise me. Have you taken a Python course?
Variables go first, then conditional branches.
How did you write this code?
0
Is this code wrong
0
Ok i converted it but still if it give me an wrong answer plz help me
0
Ok i understood thanx
0
weight and height inputs are taken as strings you need to specify the type of input to either float or int