You are on page 1of 3

Body Mass Index (BMI) Determination

print("BMI Determination\n")
height = float(input("Enter your height: "))
weight = float(input("Enter your weight: "))
bmi = weight/(height**2)
if (bmi < 18.5):
print("Your bmi is: ", bmi)
print("You are underweight")
elif(bmi >= 18.5 and bmi <= 24.9):
print("Your bmi is: ", bmi)
print("You are normal")
elif(bmi >= 25 and bmi <= 29.9):
print("Your bmi is: ", bmi)
print("You are overweight")
else:
print("Your bmi is: ", bmi)
print("You are very overweight")
Quadratic Equation
Import cmath
a = int(input("Enter the value of a: "))
b = int(input("Enter the value of b: "))
c = int(input("Enter the value of c: "))
disc = int(b**2 - 4*a*c)
if (a == 0):
print ("This is not a quadratic equation")
elif (disc > 0):
x1 = (-b + cmath.sqrt(disc))/2*a
x2 = (-b - cmath.sqrt(disc))/2*a
print ("The roots are real and distinct")
print ("x1 is: ", x1)
print ("x2 is: ", x2)
elif (disc == 0):
x = (-b + cmath.sqrt(disc))/2*a
print ("The roots are equal")
print("x is: ", x)
else:
x1 = (-b + cmath.sqrt(disc)) / 2 * a
x2 = (-b - cmath.sqrt(disc)) / 2 * a
print ("The roots are complex")
print("x1 is: ", x1)
print("x2 is: ", x2)
Combination and Permutation
print ("Calculation of combination and Permutation")
n = int(input("Enter the value of n: "))
r = int(input("Enter the value of r: "))
nr = int(n-r)
factorialn = 1
factorialr = 1
factorialnr = 1
for i in range (1, n+1):
factorialn = factorialn*i
for j in range (1, r+1):
factorialr = factorialr*j
for k in range (1, nr+1):
factorialnr = factorialnr*k
combination = int(factorialn/(factorialr*factorialnr))
permutation = int(factorialn/factorialnr)
print ("The combination is: " , combination)
print ("The permutation is: " , permutation)

You might also like