Join the conversation
# Calculating the BMI of two people and then comparing it. We are going to do this with Input function, and we will also apply conditions to check whether they have same or different BMI
# units : Matric
# Asking Names, Weight (kg), Height (m)
# Formula = Weight (kg) / [Height (m)]^2Person_1_name = input ("what is your name ?")
Person_2_name = input (" What is your name ?")Person_1_Height = float (input ("Tell me your Height in meters "))
Person_2_Height = float (input ("Tell me your Height in meters "))Person_1_Weight = float(input ("Tell me your Weight in kg "))
Person_2_Weight = float(input ("Tell me your Weight in kg "))Person_1_BMI = Person_1_Weight / (Person_1_Height ** 2)
print(Person_1_BMI)Person_2_BMI = Person_2_Weight / (Person_2_Height ** 2)
print(Person_2_BMI)if Person_1_BMI < Person_2_BMI:
print(Person_1_name,"'s BMI is less than", Person_2_name,"'s BMI")
elif Person_1_BMI == Person_2_BMI:
print(Person_1_name,"'s BMI is same as", Person_2_name,"'s BMI")
else:
print(Person_1_name,"'s BMI is greater than", Person_2_name,"'s BMI")
Reply
#asking for input from the user
the_height = float(input("Enter your height in cm:"))
the_weight = float(input("Enter the weight in kg:"))#defining a function for BMI
the_BMI = the_weight / (the_height/100)**2#printing the BMI
print("Your Body Mass Index is", the_BMI)#if_elif_else conditions
if the_BMI <= 18.5:
print("You are under weight")
elif the_BMI <=24.9:
print("You are normal weight")
elif the_BMI <=29.9:
print("You are over weight")
else:
print("You are obese")
Reply
name = input('Enter your name: ')
weight = int(input('Enter your weight in kgs: '))
height = float(input('Enter your height in meters: '))
bmi_calculator = round(weight / (height ** 2), 2)
print(f'Hello {name}! Your BMI is {bmi_calculator}')
Reply
name = input('Enter your name: ')
weight = int(input('Enter your weight in kgs: '))
height = float(input('Enter your height in meters: '))
bmi_calculator = round(weight / (height ** 2), 2)
print(f'Hello {name}! Your BMI is {bmi_calculator}')
Reply
personA=input("Enter a name of 1st person:")
personB=input("Enter a name of 2nd person:")
Age_A=input("Enter your age :")
Age_B=input("Enter your age :")
if Age_AAge_B:
Print(personB,"is younger than",personA)
else:
print(personA,"and",personB,"are of the same age")
My code
Reply
person_name = input("What is your name?")
person_weight_str = input("What is your weight?")
person_height_str = input("What is your height?")
person_weight = float(person_weight_str)
person_height = float(person_height_str)
# Calculate BMI using the formula: (weight / (height * height)) x
bmi = (person_weight / (person_height * person_height))
print("nHello, {0}, you weigh about {1} kilograms and are about {2} cm tall. Your BMI is {3}.".format(person_name, person_weight, person_height, bmi))
if bmi < 18.5:
print("You are underweight.")
elif 18.5 <= bmi < 25:
print("You are normal.")
elif 25 <= bmi < 30:
print("You are overweight.")
elif 30 <= bmi < 35:
print("You are obese.")
else:
print("You are clinically obese.")
Reply
person_name = input("Enter your name:")
person_weight = int(input("Enetr your weight in kgs:"))
person_height = float(input("Enetr your height in meters:"))bmi_calculator = round(person_weight/(person_height)**2,2)print(f"Body Mass index of {person_name} is {bmi_calculator} ")
Reply
person1_name = input("What is your name p1?")
person2_name = input("What is your name p2?")
person1_age = input("What is your age p1?")
person2_age = input("What is your age p2?")
if person1_age>person2_age:
print(person1_name, "is bigger than", person2_name)
else:
print(person2_name, "is bigger than", person1_name)
Reply
![](https://codanics.com/wp-content/uploads/2023/10/dp.jpg)
bmi_calculator = input("what is your name ")
weight = float(input("what is your weight "))
hight = float(input("what is your hight "))
# formula of bmi is wight of body is divided by hight meter square
bmi = weight/(hight*hight)
print("your bmi is", bmi)
Reply
![](https://codanics.com/wp-content/uploads/2023/10/dp.jpg)
person_a = input("person a ka name kia hai ")
person_a = input("person a is age kia hai ")
person_b = input("person b ka name kia hai ")
person_b = input("person b ki age kia hai")
if person_a > person_b:
print("person a bara hai yr b sa ")
elif person_a<person_b:
print("person a chota hai person b sa ")
else:
print("dono ki age same hai yara")
Reply