 Hello, everybody. Today, we're going to be working on building a BMI calculator in Python. Now, before we get started, I want to show you this BMI calculator that I found online, and it shows you the basic calculation that they use, and that's the one we're going to use in this video. And they also have this calculator right down here, and some ranges that we can use for our calculator as well. So for reference, I weigh about 170 and about 59. Let's calculate this. So I'm about a 25.1 BMI which falls into the overweight category. That's unfortunate. But we can see exactly how this works and how ours should work when we actually build it. So we're going to kind of reference this throughout the video. So let's go right over here to our BMI calculator. We need to calculate weight and height, and then run this calculation right here. So let's go ahead and copy this. And we're going to put it right down here. And so now we have our calculation. So what we need is we need input from a user, and there is an input function within Python that we're going to be using. So let's actually give me a few more cells. So the first thing that we need to calculate is their weight. Let's type out weight right here. We'll say weight is equal to, and this is where we'll use our input function. So we'll say input. And when we actually run this, it's just going to give us this blank square or a user can input something. We'll say Alex. So this is our output is what the actual user input. And it does save it to this variable. So if we say print weight, it will still print out Alex. Now this is where we want the user to, just like we did before, where they'll input their weight. So we want to kind of give them a prompt for this. We'll put a string in here. So I'll do a double quote. And then I'll say enter your weight in, and we're using pounds. I'll say pounds, fallen space. So now when we do this, it'll say enter your weight in pounds. I'll say 170. And then when we run this, it does store that. Now let's do print. I should have saved it. Wait again. Now it's only storing the value of 170. It's not actually storing this string right here. So that's really important for when we do our calculations later. I'm going to save this right down here because I'm sure I'm going to use that later. So we have that as working. Now we need to also do our height. So let's copy this and we'll put it right here. And we'll do height and enter your height in inches. So now for this one, if we hit enter, that's actually running. Let's stop it really quick and interrupt it. Let's try running this. So it's going to say enter your weight in pounds. That's the first input, say 170. And then when I hit enter, it's going to prompt me for that second input. And so in inches, five, nine is 69 inches. And then I can hit enter again. And now we have both of our inputs. Now we need this calculation right down here. And just like that. So now we have weight in pounds times 703 divided by height in inches by height in inches. So we actually have weight and it's already written in there, but I'm just going to do it like this. We'll do weight times 703. So that's pounds that are weight in pounds times 703 divided by now we have our height in inches times the height in inches. So this is our calculation right here. So let's do this exact same thing. Let's run this. And this times of course is not going to work. We need to do our star for both of these. All right. Now this is our calculation. So let's run this. So we have 170 and that's pounds and inches was 69 hit enter. And it says cannot multiply the sequence of non integer type of string. Ah, that's because these are being stored in strings. They're right down here. I do and we'll do type of height. We run that this is actually a string. So we want to change that because we don't need that anymore for that. So we don't want it to be a string. We need those to be integers or floats or really anything besides a string just needs to be numerical. So integer float really. So let's do integer and we'll wrap that input in it. And we'll do the same thing for this one. Now we have an integer for our weight and integer for our height. So now when we're running this calculation, it should work properly. Let's run this again. Our pounds are 70. Our height is 69 inches. And it's not giving us our output because we're not printing anything. Okay. So I just need to do print BMI. So let's try this again. 170 69 and there is our BMI 25.1. So it worked the exact same as this one. So they input, well, we input our height. We input our or we input our weight. We input our height and then it calculated our BMI. The next thing that we need to do is we need to kind of give the user some context. Is that good? Is there BMI in within a good range, a bad range? We don't know. So let's go ahead and I'm going to see if I can copy this. No, if this will work or not. Let's go ahead and copy us right down here. Perfect. So what we now need to do is we need to say, okay, if the user has given us this input, we want to give them or tell them if they are a normal weight, overweight, obese, severely obese, anything like that. And we have these ranges. So that should help us out quite a bit. So let's just write our if statement and then we'll include it up here. But let's go down here and we'll say if and then we'll do BMI. And let's just say BMI is greater than zero. So if it's greater than zero, if they had any input where the BMI was not zero, which should be every time if they do it properly and they don't, you know, put a string in there or something or type out 40, which maybe we should make a prompt for that if that happens. Then we can say if we'll do BMI. And now we need to give that first range. So this range right here. So if it's under 18.5, so we need to do a less than. So if it's less than 18.5, and it just says under, it doesn't say under or equal to. So I'll keep it at 18.5. So if it's under 18.5, then let's give kind of the output. We'll say print and the output or the basically the prompt is underweight. So we'll just say you are under case underweight and just like that. Then we're going to pass several ELF statements through here. Well, let's just say else. So I guess this would be like if they are, if they don't input something properly or something messes up, maybe we could write something like print. I'm thinking all this through. We can write print enter valid inputs or something like this. We can always change that. But let's really quickly let's run this. Okay, so I'm not in that range. Let's make the next one. So then I can be within a certain range. And we need, we should need one more at a minimum. So we'll say ELF and ELF. These next two are this 24.9. So it's going to check this one first. So if it's 18.5 or below 18.5, it's automatically going to print this one. So this next one, we don't have to do like a range or anything. We can just say if it's below, if it's between 25 and 29.9. So this one actually should be less than or equal to this one is normal. Oh, whoops, 24.9. So this one is 24.9. This one is going to say you are normal weight. So let's run this now. Let's see, BMI was 25.1. Oh, guys, I'm just messing up here. I apologize. All right, this is the one that I was part of. So now it's going to be part of the overweight crowd. Now let's run this. And now our prompt is you are overweight. Because remember, the BMI was saved right here as 25.1 down here. If we run through this, it's saying no, you're not an oops. Get rid of that. No, you're not in under 18.5. You're not under 24.9. If you are under 29.9, you are overweight. So that did work properly. So that's really good. And I don't think I want this to be our output for the person. Because we're going to add this up here. It's just going to give us the BMI. And then the output is going to say you are overweight. Let's make it a little bit more customized. I'm going to say name is equal to input. And then we'll say enter your name. So it'll be enter your name. We'll do Alex, 70, 69. There's our BMI. Now it's going to run through this logic, or it will run through this logic in just a second when we actually finish this. Then we have 34.9. Let's do one more. And then this one's going to be for 39.9. So this one was overweight. This one is obese, severely obese. So we'll say severely obese. And then anything that's over, that 40 and over. So if it's not this one, anything else should be morbidly obese. So actually this else statement right here should say you are severely obese. This is going to say morbidly, morbidly obese. Now I added that name up here because I wanted to add that down below actually. So we're going to say name plus and then we'll do like you are underweight. So it'll be a little bit more personalized. I think it'll be a nice touch. I really do. We'll do it like this and we'll say you. Let's go back and do that to all of them. And let me see how quickly I can do this. Oh, whoops, what did I do? Get rid of that. Name plus you like that. Geez, you guys have seen me mess up eight hun. Name plus you and then name plus you. So now let's run this and now it's a little more personalized. This is Alex. You are overweight. So this is all really good. Now this is an if statement. What we had done before I think is actually what we should put right down here. So we'll say else and then if that doesn't work, we'll say what do we say enter valid input. We'll just put that and let me see if I can test this out. Don't I don't know if this will air out or if this will even work. Let me just see if I can mess with it and see if I can get it to work. Actually, let's copy this. We're going to copy this whole thing. We're going to include it right here. And now we have basically our entire calculator. So let's run this. Enter your name. We'll say Alex. Enter your pounds 170. Enter your inches 69. And then it's going to say 25.1. Alex, you are overweight and that's perfect. We could even go as far as adding like some feedback. We say you are overweight and then it would be a period. And we could say you need to exercise more. Stop sitting and writing so many Python tutorials. So now if we run this, we'll do Alex 170 69. It says Alex, you are overweight. You need to exercise more and stop sitting and writing so many Python tutorials. Period. And that's it. This is the entire project. You can go a ton farther. You can include much more complex logic. You could even build out a UI to create your own, you know, app just like this, where it has this input and this UI. You can build that out with in Jupyter notebooks with Python. But that's not really what this tutorial is for. This is just to kind of help you think through some of the logic of creating something like this. So, you know, I hope that this was helpful. I hope that this was fun. I like creating stuff like this. We have two other projects that we're going to do and maybe I'll include more. But we have two right now that I have planned. And I hope those are helpful. This is probably our easiest one. And they'll get a little bit more difficult in the next projects. So I hope that this was fun. I hope that this was helpful and that you can now kind of utilize those Python skills that you've been working on. If you like this video, be sure to like and subscribe below. And I'll see you in the next video.