Skip to content

Instantly share code, notes, and snippets.

@nadia2012
Created March 12, 2012 01:25
Show Gist options
  • Save nadia2012/2019158 to your computer and use it in GitHub Desktop.
Save nadia2012/2019158 to your computer and use it in GitHub Desktop.
hw
#nadia
#wjowd
data = [
{"name":"Ali Khalid", "weight":80.6, "height":1.78},
{"name":"Dalal Yousef", "weight":52.2, "height":1.65},
{"name":"Deema Sulaiman", "weight":160, "height":1.80},
{"name":"Aseel Salim", "weight":42.8, "height":1.67},
{"name":"Bader Abdulla", "weight":96, "height":1.79},
{"name":"Abrar Adel", "weight":77, "height":1.60},
{"name":"Mohammed Fahad", "weight":75.4, "height":1.91},
{"name":"Fawaz Essa", "weight":59.3, "height":1.86},
{"name":"Ghalia Hamad", "weight":56.6, "height":1.71},
]
def bmi_calculate():
weight = float(input('Enter weight in pounds: '))
height = float(input('Enter height in inches: '))
# Weight cannot be less than 0 or greater than 500
if weight <= 0 or weight >500:
print 'Weight cannot be less than 0 or greater than 500'
#continue
# Height cannot be less than or equal to 0 inches
elif height <= 0:
print 'Height cannot be less than 0'
#continue
else:
bmi = (weight / (height * height)) * 703.0
print 'Your BMI is %.2f' % bmi
if bmi <= 18.5:
print 'Your weight status is Underweight'
elif bmi >= 18.5 and bmi <= 24.9:
print 'Your weight status is Normal weight'
elif bmi >= 25 and bmi <= 29.9:
print 'Your weight status is Overweight'
elif bmi >= 30:
print 'Your weight status is Obese'
def result(d):
for x in d:
name = x["name"]
age = raw_input("How old are you? ")
height = x["height"]
weight = x["weight"]
return height_squared = pow(height, 2) return " deer %r ,so you are %r years old, %r meters tall, weigh %r kilograms and have a BMI of %r" % (name ,age, height, weight, bmi)
#this is the second solution i tried also
def bmi_calculate():
BMI (kg/m^2) = weight / height * height
weight, height = raw_input("Enter weight and height seperated by a comma:")
print "the BMI is:" , bmi
for bmi_calculate < (18.5):
return 'Underweight'
if n in range (18.5 , 24.9):
return "normal"
if n in range (25 , 29.9):
return "overweight"
elif n > 30:
return "obese"
def height(a):
total = 0
count = 0
for x in a :
n = x["height"]
age = raw_input("How old are you? ")
height = float(raw_input("How tall are you in meters? "))
weight = float(raw_input("How much do you weigh in kilograms? "))
height_squared = pow(height, 2)
bmi = weight / height_squared
print "so you are %r years old, %r meters tall, weigh %r kilograms and have a BMI of %r" % (age, height, weight, bmi)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment