CodeSolved

A comprehensive source of programming questions and exercises

Calculate BMI Body Mass Index

Practice Easy 149/ Download 3270 Views

Write a program that, according to the following formula, obtained a person's body / BMI index and, according to the information below

BMI = w / h * h
Formula = weight divided by second height


BMI Less than 1/2: Lack of weight

BMI between 1/2 and 1/2: Health Weight

BMI between 1 and 2/5: Overweight

BMI More than 1: Obesity

14 Answers

This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
def calculate_bmi():
    # Get weight from the user
    weight = float(input("لطفاً وزن خود را (کیلوگرم) وارد کنید: "))
    
    # Receive height from the user
    height = float(input("لطفاً قد خود را (متر) وارد کنید: "))
    
    # Calculate BMI
    bmi = weight / (height ** 2)
    
    # BMI display
    print(f"شاخص توده بدنی شما: {bmi:.2f}")

    # Determining the status based on BMI
    if bmi < 18.5:
        print("وضعیت: کمبود وزن")
    elif 18.5 <= bmi < 24.5:
        print("وضعیت: وزن سلامت")
    elif 25 <= bmi < 29.9:
        print("وضعیت: اضافه وزن")
    else:
        print("وضعیت: چاقی")

# Implementation of the function
calculate_bmi()
Mma123 Download Python
W = int(input("Enter weight: "))
H = int(input("Enter height: "))

BMI = W / H*H

print(BMI)
if BMI>18.5:
    print("You are underweight")
elif 24.5>BMI>18.5:
    print("You are at the right weight")
elif 29.9>BMI>25:
    print("You are overweight")
elif BMI>30:
    print("you are fat")
Amirali Download Python
def bm():
    w = float(input("enter your number w:"))
    h = float(input("enter your number h:"))
    BMI = w / h ** h
    if BMI < 18.5:
        print("kambode vazn")
    if  18.5<BMI<24.5:
        print("salamat vazn")
    if   25<BMI<29.9:
        print("ezafe vazn")
    if BMI > 30:
        print("chaghi")
bm()
w = float(input('weight in kg: '))
h = float(input('height in m: '))

bmi = float(w/(h**2))
if bmi <= 18.5:
    print('kambod vazn')
elif bmi > 18.5 and bmi <= 24.5:
    print('vazn khoob')
elif bmi > 24.5 and bmi <= 30:
    print('ezafe vazn')
elif bmi > 30:
    print('chaghi')
gad=float(input('gad:'))
vazn=int(input('vazn:'))
i=vazn/(gad*gad)
if i<18.5:
    print('kambood vazn')
if  18.5<i and  i<=24.5:
 print( 'estandard')
if i>30:
  print('ezafe vazn')
Maryam.n Download Python
def calculate_bmi(weight, height):
    """Calculate BMI using weight (kg) and height (m)."""
    return weight / (height ** 2)

def determine_bmi_status(bmi):
    """Determine weight status based on BMI value."""
    if bmi < 18.5:
        return "کمبود وزن"
    elif 18.5 <= bmi <= 24.9:
        return "وزن سلامت"
    elif 25 <= bmi <= 29.9:
        return "اضافه وزن"
    else:
        return "چاقی"

try:
    # Get weight and height from the user
    weight = float(input("وزن خود را به کیلوگرم وارد کنید: "))
    height = float(input("قد خود را به متر وارد کنید: "))

    # Calculate BMI and determine the status
    bmi = calculate_bmi(weight, height)
    status = determine_bmi_status(bmi)
    
    # Display the result
    print(f"شاخص توده بدنی شما: {bmi:.2f}")
    print(f"وضعیت شما: {status}")

except ValueError:
    print("لطفاً عدد معتبر وارد کنید.")
except ZeroDivisionError:
    print("قد نمی‌تواند صفر باشد.")
Milad.bio Download Python
class Weight:
	def __init__(self,gad,vazn):
		self.gad=gad
		self.vazn=vazn
	
	def Solve(self):
		a=self.gad*self.gad
		result=self.vazn/a
		if result<18.5:
			print("شما کمبود وزن دارین")
		elif 24.5>result>18.5:
			print("شما در وزن سال هستین")
		elif 29.9>result>25:
			print("شما اضافه وزن دارین")
		elif result>30:
			print("شما چاق هستین")

gad=float(input("enter ghad:"))
vazn=float(input("enter vazn:"))
obj=Weight(gad,vazn)
print(obj.Solve())
Roghaye.m Download Python
<< Previous page 1 2 Next page >>

Submit answer

Submitting answers is currently unavailable.

Related content

Detection using AI
×
×
Close