Page 92 - Trackpad_V4.0_C8_Flipbook
P. 92
But there might be situations when we need to check for multiple conditions in a program. For example,
look at these programs:
username = "Orange"
password = "secure123"
IF username = "Orange" AND password = "secure123" THEN
PRINT "Access granted"
ELSE
PRINT "Access denied"
Access granted
user_type = "member"
coupon_value = "invalid"
IF user_type = "member" OR coupon_value = "valid" THEN
PRINT "Eligible for discount"
ELSE
PRINT "Not eligible for discount"
Eligible for discount
What did you notice?
Both the programs have two IF conditions joined together using AND or OR. The final result depends
on the combined result.
AND: results in true only if both the conditions are true. If any one condition is false, the result will be
false.
OR: results in true if any one of the conditions is true. If both are false, the result will be false.
Now, write your answers for both.
1. age =20 2. shop = 500
IF age >= 12 AND age <= 19 THEN customer = "new"
PRINT "You are a teenager" IF shop > 100 OR customer = "old" THEN
ELSE PRINT "Eligible for a free gift"
PRINT "You are not a teenager" ELSE
PRINT "Not eligible for a free gift
90 Premium Edition-VIII

