Why is it only “Height” set to a type as “float” | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why is it only “Height” set to a type as “float”

Weight is in kg, height is in meters. Note, that height is a float. ABOVE TEXT IS FROM THE BMI TASK IN PYTHON WHAT ABOUT WEIGHT TYPE?

28th Feb 2021, 11:12 PM
{Short Break atm} Claus Arnt Rasmussen
{Short Break atm} Claus Arnt Rasmussen - avatar
4 Answers
+ 2
Usually, height is measured in cm. But we need to convert it to meters for calculations. So that's why we are supposed to use float(). Because decimals will be lost if we use int() instead of float(). Mostly weights are integers. It doesn't matter if we use float() for weight :)
1st Mar 2021, 2:51 AM
Simba
Simba - avatar
+ 1
I’ve set both type as float in the BMI task because not all people have a straight weight like 50, 64 or 83 Kg. and this give the correct answer of your BMI number ❤️
28th Feb 2021, 11:17 PM
{Short Break atm} Claus Arnt Rasmussen
{Short Break atm} Claus Arnt Rasmussen - avatar
+ 1
like or dislike is awsome! but special dislike would be nice if they left a comment. I’m here to learn and could be very wrong in my Q&A
28th Feb 2021, 11:27 PM
{Short Break atm} Claus Arnt Rasmussen
{Short Break atm} Claus Arnt Rasmussen - avatar
+ 1
Thank you very much Simba I understand why we use float and special to heights but Personal I would also use float to weight. but nothing was told about weight type in the task. I believe float will give more accurate result and no input error from the user
1st Mar 2021, 2:58 AM
{Short Break atm} Claus Arnt Rasmussen
{Short Break atm} Claus Arnt Rasmussen - avatar