12/18/2023 0 Comments Bmi calculator age genderGender = str(input('Are you male (M) or female (F): '))Īge = int(input('Please enter your age in years: '))īmr = 655 + (4.35 * weight) + (4.7 * height) - (4. If bmi < 18: # First step, is it less than 18?Įlif bmi <= 24: # If it isn't is it less than or equal to 24?Įlif bmi <= 29: # If not is it less than or equal to 29?Įlif bmi <= 39: # If not is it less than or equal to 39?Įlse: # If none of the above work, i.e. # take it elsewhere where it will be used once only # Never write code more than once, either place it in a function or # Get user's height, weight and age values If output != 'BMI' and output != 'bmi' and output != 'BMR' and output != 'bmr': Print('Exiting.') # Try to always notify the user about what is going on Being overweight increases the risk of a number of serious diseases and health conditions. Chart for boys Chart for girls Risks associated with being overweight. The Centers for Disease Control and Prevention (CDC) BMI-for-age percentiles growth charts. If output = 'exit' or output = 'Exit' or output = 'EXIT': BMI chart for children and teens, age 2-20. # Exit, I put it up here to make sure the next step doesn't trigger Print ('You entered: ' + output) # Try not to print 'random' info # Ask whether to print BMI, BMR, or to exit There are a few other tidbits that will show themselves in the code below, I've heavily commented the code so you can understand it thoroughly. You are reusing the same code way too much, this should be fixed. The if and elif are very badly used, if is for a condition, elif is run if the subsequent if hasn't been satisfied, and if the code within the elif has, while the third one, else is more of a default statement, per se, if nothing was satisfied go to this one. Here is a tutorial to get you started on that. The or logical operator cannot be used like that, this is most prominent in the main if statements. There are many bugs or inconsistencies within your code, here are a few main ones. Weight = int(input('Please enter your weight in pounds'))Īge = int(input('Please enter your age in years'))īmr = 66 + (6.2 * weight) + (12.7 * height) - (6.76 * age)īmr = 655 + (4.35 * weight) + (4.7 * height) - (4.7 * age)Įlif output = 'exit' or 'Exit' or 'EXIT': Height = int(input('Please enter your height in inches')) #Get user's height, weight and age values. Gender = input('Are you male (M) or female (F) ') Weight = int(input('Please enter your weight in pounds: ')) Height = int(input('Please enter your height in inches: ')) Output = str(input('Calulate BMI or BMR or Exit: ')) I have got the code down yet when i select bmi, it goes through the bmi process then immediately after it has finished it runs the mbr, then the program crashes? Well i am trying to make a bmi & bmr calculator.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |