00:01
On this program we'll write code to calculate bmi of a user to calculate bmi we'll take two inputs that is weight and height of user we'll take weight in pound and height in feet and inches like five feet ten inches so the formula to calculate bmi is weight in kz divided by square of height in meters.
00:41
You can see we have weight in pound and then height in feet and inches.
00:46
Let's convert this height which is in feet and inches to a total of inches.
00:53
To do that we can use a formula feet into 12 plus inches.
01:00
That is on this formula feet into 2 valve gives total number of inches in that feet because one feet has 2 1 by inches.
01:13
Now if there is 5 feet then 5 will be multiplied by 2 well and then rest of the inches will be added like for this case where user has given 5 feet 10 inches that will be 5 into 12 plus 10 that is 5 into 2 valve gives us 60 and then 10 gives us total of 70 inches.
01:38
Now that we have height in inches what we need to do is this height into meter to do that we'll use some constant which has like say constant c which has value of to 0 .0254 so if we multiply 70 by 0 .054 it will give height in meters similarly for pound we'll use a constant 0 .45359 which will convert the weight that is in pound into cases.
02:19
Now that we have these values we can use this formula to calculate bmi.
02:24
After we have a score for bmi what we need to do is we need to show them if we need to show users if their bmi score is either underweight or normal or overweight or obvious.
02:40
So if the bmi score is less than 18 .5 that is underweight if it is greater than 18 .5 and less than 25 then it will be normal if it is greater than 25 but less than 30 then that's overweight similarly if the weight is greater than 30 then the bmi is obvious okay, now that we know how we will be calculating bmi and how we will be showing the results, depending on the bmi score of the user, now we can start writing program in python.
03:42
So let's start writing program in python.
03:46
Here i'll be asking weight first.
03:52
We are saving weight in pounds and weight will be stored in this variable call, sorry, weight.
04:04
So after eval we'll also need a method called input so this will ask for user input in console so let's say enter weight in pounds and let's close bracket for input and then another bracket for eval after that list asks for feet and store it in a variable called feet same as weight will write eval input enter feet and close two brackets after that let's ask for inches so now we have weight in a variable called weight and then height in a variable called feet and inches so right now we have feet and inches so we need to convert these feet and inches in a total of inches and store it in a variable name height to convert feet into inches we'll multiply it by 12 and add additional part of the height that is stored in a variable called inches now that we have height in inches and weight in pound and we need few constants to convert these values into kilograms and meter...