Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python **
#1
May I ask why Python is calculating the height**2 differently. The height should be 3.2?


def bmi(name, height, mass):
h = (height ** height)
print('Height on p:', h)
print('The mass is: ', mass)
rez = mass / h
print(rez)
if rez < 18.5:
print(name + " is Underweight")
elif rez >= 18.5 and rez < 24.9:
print(name + " has Normal Weight")
elif rez >= 25 and rez <=29.9:
print(name + " is Overweight")
elif rez > 30:
print(name + " is Obese!!!")

ex = bmi('name', 1.8, 94)


OUTPUT:
Height on p: 2.880650097068328
The mass is: 94
32.63152303560398
name is Obese!!!
metulburr write Oct-19-2020, 11:22 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply
#2
Nowhere in your code have you asked for height ** 2 (or for height * height, which would be the same thing).

Instead you have coded height ** height, which is a different expression.
Reply
#3
That is height raised to the height power.
BTW - when learning a new language I start with a BMI calculator. Welcome!
Reply
#4
(Oct-19-2020, 11:12 PM)jefsummers Wrote: That is height raised to the height power.
BTW - when learning a new language I start with a BMI calculator. Welcome!

Thank you for your feedback :)

Here is the final version of my BMI calculator. Any other idea that can be good project?
[Image: ff.png]
Reply
#5
Might get some ideas from this site:
Python projects for beginners and beyond
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020