Unit3-If-else Statement
Unit3-If-else Statement
Example:
if mark >= 50:
print “PASS…Congrats!” #(statement-1)
else:
print “FAIL….Need to study hard” #(statement-2)
Python Operators
Output
Enter the marks = Enter the marks = Enter the marks =
90 60 45
Your Grade is A Your Grade is B Your Grade is F
BYE BYE BYE
Solution
mark=float(input("Enter the marks = "))
if mark>=80 and mark<=100:
print("Your Grade is A")
elif mark>=60 and mark<=79:
print("Your Grade is B")
elif mark>=50 and mark<=59:
print("Your Grade is C")
elif mark>=0 and mark<=49:
print("Your Grade is F")
else:
print("Your input is wrong!!")
print("BYE")
Practice program
Solution
Solution
weight=float(input("Enter Weight="))
height=float(input("Enter Height="))
bmi=weight/(height*height)
bmi=round(bmi,2)
print("your BMI=", bmi)
if bmi<18.5:
print("You are under weight; You need to eat well")
elif bmi<25:
print("You are normal weight; Congratulation! Keep
it up")
else:
print("You are overweight; you need to do more
exercise")
Program to check whether a number is even or not.