python ** - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: python ** (/thread-30402.html) |
python ** - Maryan - Oct-19-2020 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!!! RE: python ** - bowlofred - Oct-19-2020 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.
RE: python ** - jefsummers - Oct-19-2020 That is height raised to the height power. BTW - when learning a new language I start with a BMI calculator. Welcome! RE: python ** - Maryan - Oct-25-2020 (Oct-19-2020, 11:12 PM)jefsummers Wrote: That is height raised to the height power. Thank you for your feedback :) Here is the final version of my BMI calculator. Any other idea that can be good project? RE: python ** - jefsummers - Oct-25-2020 Might get some ideas from this site: Python projects for beginners and beyond |