In: Computer Science
Post a Python program that accepts at least three values as input, performs some computation, and displays at least two values as the result. The program must include an if statement that performs different computations based on the value of one of the inputs. Include comments in your program that describe what the program does. I would like to see a program that is simple like BMI calculator or any other program that can be used in a real-life situation like budgeting or tile/flooring installation etc thanks.
CODE
print("\nBMI CALCULATOR")
# reading inputs age, height, weight from user
age = int(input("Enter age: "))
height = float(input("Enter height(in metres): "))
weight = float(input("Enter weight(in Kg): "))
# checking if age is greater than or equal to 18
if(age >= 18):
# if yes
# calculating bmi value
bmi = weight / height ** 2
# checking the bmi range for calculated bmi value
# if bmi less than 18.5, then Underweight
if(bmi < 18.5):
print("BMI value:", bmi, "\tUnderweight")
# if bmi greater than or eqoal to 18.5 and less than or equal to 24.9, then Normal weight
elif(bmi >= 18.5 and bmi <= 24.9):
print("BMI value:", bmi, "\tNormal Weight")
# if bmi greater than or eqoal to 25 and less than or equal to 29.9, then Over weight
elif(bmi >= 25 and bmi <= 29.9):
print("BMI value:", bmi, "\tQverweight")
# if bmi greater than or equal to 30, then Obese
elif(bmi >= 30):
print("BMI value:", bmi, "\tObese")
# else condition for age
else:
# if no
# prints that age should be 18 or greater
print("Age should be greater than or equal to 18")
CODE SCREENSHOT
OUTPUT
Age restriction