Page 201 - AI Ver 1.0 Class 10
P. 201
if (condition1 evaluates to True): Num=int(input("Enter the number: "))
Statements for condition1 will be executed if Num%2==0:
elif (condition2 evaluates to True): print("Even Number")
Statements for condition2 will be executed elif Num%3==0:
elif (condition3 evaluates to True): print("Multiple of 3")
Statements for condition2 will be executed elif Num%5==0:
. print("Multiple of 5")
. else:
. print("Invalid Number")
else:
Statements executed when all above conditions are
False
Few examples of conditional statements:
1. if Age>18:
print("Eligible for Voting")
else:
print("Not Eligible for Voting")
2. if Year%4==0 or Year%100==0 and Year%400==0:
print("Leap Year")
else:
print("Not a Leap Year")
3. if Gender=="M" and Age>=21:
print("Eligible for Marriage”)
elif Gender=="F" and Age>=18:
print("Eligible for Marriage")
else:
print("Invalid Input")
4. if Marks<33:
print("Fail")
else:
print("Pass")
5. if N1>N2 and N1>N3:
print("Num1 is largest")
elif N2>N1 and N2>N3:
print("Num2 is largest")
elif N3>N1 and N3>N2:
print("Num3 is largest")
else:
print("Invalid Choice")
Advance Python 199

