+ 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ā€™

8th Jun 2022, 2:52 AM
Mohamed Hytham
24 Respostas
+ 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
8th Jun 2022, 2:55 AM
Emerson Prado
Emerson Prado - avatar
+ 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.
9th Jun 2022, 9:42 AM
Emerson Prado
Emerson Prado - avatar
+ 3
You are trying to split string variables that need to be converted to numeric variables.
8th Jun 2022, 3:18 AM
Solo
Solo - avatar
+ 2
Make it x = (weight/height**2) not (weight/height/height).
9th Jun 2022, 1:56 AM
Vighnesh Shukla
Vighnesh Shukla - avatar
+ 1
What do you mean
8th Jun 2022, 3:19 AM
Mohamed Hytham
+ 1
Data entry is in the form of a string even when you enter numbers.
8th Jun 2022, 3:42 AM
Solo
Solo - avatar
+ 1
So you mean to convert the input to a float
8th Jun 2022, 3:43 AM
Mohamed Hytham
+ 1
Yes
8th Jun 2022, 3:45 AM
Solo
Solo - avatar
+ 1
You have all the conditions nested in one if(x< 18.5)
8th Jun 2022, 3:59 AM
Solo
Solo - avatar
+ 1
I made the code and itt is write cuz of ur help thank you very much
8th Jun 2022, 4:00 AM
Mohamed Hytham
+ 1
Happy coding!
8th Jun 2022, 4:03 AM
Solo
Solo - avatar
+ 1
Change your height to float: Height = float()
8th Jun 2022, 7:39 PM
EmmzyCodez
EmmzyCodez - avatar
+ 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.
12th Jun 2022, 7:39 PM
Emerson Prado
Emerson Prado - avatar
0
šŸ˜³ What exactly do you not understand in my answer?
8th Jun 2022, 3:25 AM
Solo
Solo - avatar
0
What is meant by numeric variables
8th Jun 2022, 3:26 AM
Mohamed Hytham
0
šŸ˜³ you surprise me. Have you taken a Python course? Variables go first, then conditional branches. How did you write this code?
8th Jun 2022, 3:39 AM
Solo
Solo - avatar
0
Is this code wrong
8th Jun 2022, 3:39 AM
Mohamed Hytham
0
Ok i converted it but still if it give me an wrong answer plz help me
8th Jun 2022, 3:45 AM
Mohamed Hytham
0
Ok i understood thanx
8th Jun 2022, 3:50 AM
Mohamed Hytham
0
weight and height inputs are taken as strings you need to specify the type of input to either float or int
9th Jun 2022, 4:51 PM
Wamy Trevor