Building a BMI Calculator with Python | Python Projects for Beginners

preview_player
Показать описание

In this tutorial we will walk through how to create a BMI Calculator in Python!

Project Code in Github:

Favorite Python Courses:
____________________________________________

SUBSCRIBE!
Do you want to become a Data Analyst? That's what this channel is all about! My goal is to help you learn everything you need in order to start your career or even switch your career into Data Analytics. Be sure to subscribe to not miss out on any content!
____________________________________________

RESOURCES:

Coursera Courses:

Udemy Courses:

*Please note I may earn a small commission for any purchase through these links - Thanks for supporting the channel!*
____________________________________________

BECOME A MEMBER -

Want to support the channel? Consider becoming a member! I do Monthly Livestreams for Members and you get some awesome Emoji's to use in chat and comments!

____________________________________________

Websites:
📱Instagram: @Alex_The_Analyst
____________________________________________

*All opinions or statements in this video are my own and do not reflect the opinion of the company I work for or have ever worked for*
Рекомендации по теме
Комментарии
Автор

i liked this video, very informative, so after watching all the python beginners, i wrote something like that, also utilizing function
def bmi(w, h):
b=(w*703)/(h**2)
return b
weight=float(input("Enter your weight in pounds"))
height=float(input("Enter your height in inches"))
yourbmi=bmi(weight, height)
print("your bmi is:")
print(round(yourbmi, 2))

if yourbmi<18.5:
print("you are Underweight")
elif (yourbmi >=18.5 and yourbmi <24.9):
print("your weight is normal")
elif (yourbmi >=24.9 and yourbmi <=29.9):
print("you are overweight")
elif (yourbmi >29.9 and yourbmi <34.9):
print ("you are obese")
elif (yourbmi >=34.9 and yourbmi <39.9):
print ("you are severely obese")
else :
print ("you are morbidly obese")

chahineatallah
Автор

This is great! I went off script and created a guide for dog owner's that tells them their dog's exercise needs by breed.

CaitlinLemon-sv
Автор

Great video Alex. Very informative. I'm in the UK, so have added an additional nested if statement to allow users to select metric or imperial system:

input_type = input("Enter 1 for metric or 2 for imperial measurements.")
if input_type == "1":
# Code for metric BMI

# BMI = weight in KG / height in m **2

elif input_type == "2":
# Code for imperial / US BMI as in video

else:
print("Please enter valid input")
# Nested if for feedback on BMI

MiriJane
Автор

Enjoyed the video. I’ve used if/else statements, input functions, and while loops to make a choose your own story that was really ridiculous. I enjoyed it a lot.

traetrae
Автор

Correction with the above code: All of the end limits should be less than or equal to just like the first one done by Alex. Otherwise, if the weight just has less than 29.9, it gets categorized under the wrong weight range.

if BMI>0:
if BMI<18.5:
print(name, ', you are Underweight')
elif BMI<=24.9:
print(name, ', you are Normal Weight!')
elif BMI<=29.9:
print(name, ', you are Overweight')
elif BMI<=34.9:
print(name, ', you are Obese')
elif (BMI<=39.9):
print(name, ", you are severely obese.")
else:
print(name, ", you are morbidly obese.")
else:
print("Enter valid input")

srdivz
Автор

Thanks Alex! I really love how clear you are doing everything.

onlytruth
Автор

lol i laughed so hard at the "well thats unfortunate" line.

vectoralphaSec
Автор

Super cool! Thanks for sharing and I also echo the sentiment that we all cannot wait for your courses to be released! Even though I just finished the Google Data Analytics course, I would LOVE to take yours also. Hope your new year is starting off exciting!

elmago
Автор

Hey, Alex! One more stage is done! All works nicely!!! I'm diving deeper :)
Thanks much for all you do for us!!!

Andrei_Neo
Автор

Would love to see Level 2 of this, where we see you build out the UI

santiagovera
Автор

Can't wait for your course to be out Alex. Nice one with the BMI calculator

taiwoadewumi
Автор

Hah, if you didn't sit and wrote so many Python tutorials. Who could've helped these more than 40k people learn Python? Thanks a lot for this course.

XB_HaidyX
Автор

For anyone interested in doing this for an aussie version i used the input " weight = float(input ("Enter your weight in kilograms: "))
height = float(input ("Enter your height in meters: ")), BMI = weight / (height ** 2)" I forgot that the Integers don't include decimal or fraction numbers so I used the Float command instead.

goldhawke
Автор

Happy new year alex! Looking forward to watching this.

danspearo
Автор

Well, this was a very satisfying project. Simple, but very helpful. I can see how this can be applied to many other simple calculations. As always, THANK YOU!! And MERRY CHRISTMAS!! I hope your 2024 is filled with light, love, laughter, health, joy, and much prosperity (especially Analyst Builder!) for you and yours Alex!!

sj
Автор

'Well that's unfortunate' made me chuckle

martinologunja
Автор

Excellent work, hope to see more videos like this project..
FYI: the comment on <29.9 was lit bit personally lol. Good luck on your workout

SaadF-pfvj
Автор

Hi Alex! Great course! Learning a lot! Thanks!
I know this tutorial for beginners, but anyway I'd like to comment that there's a better approach to the if-elif-elif-elif code (commonly known as arrow anti-pattern) in this case.
Having a reference table as the source for the logic allows possible future changes (e.g. if the IBM values change for some reason) WITHOUT having to change the logic of the code, only the data contained in the table would be modified in that case.

Something like this:

ref_table = [ { 0.0 : "a feather" },
{ 18.5 : "underweight" },
{ 24.9 : "normal weight" },
{ 29.9 : "overweight" },
{ 39.4 : "obese" },
{ 39.9 : "severely obeese" },
{ 99.9 : "morbidly obese" },
{ 999.9 : "life-threatening obese" }
]

name = input("Enter your name: ")
weight = int(input("Enter your weight in pounds: "))
height = int(input("Enter your height in inches: "))
BMI = (weight * 703) / (height * height)

for pos in range(len(ref_table)):
if ( BMI >= and BMI < ):
print(name + ", your BMI is " + str(int(BMI)) + ". You are " +

fede
Автор

Thank you so much for a fun tutorial on BMI calculator!!!

syauqiamran
Автор

hey small suggestion for better asthetics, Instead of just BMI , using > print (" BMI is", BMI)

saptaparnidasac
join shbcf.ru