1. Simple If
set age to 18
if age >= 18 then
say "Adult"
end
2. If Else
set age to 15
if age >= 18 then
say "Adult"
else
say "Minor"
end
3. Weather Check
set weather to "clear"
if weather is "clear" then
say "Go outside"
end
4. Marks Pass Fail
set marks to 70
if marks >= 40 then
say "Pass"
else
say "Fail"
end
5. Elif Example
set score to 85
if score >= 90 then
say "A"
elif score >= 75 then
say "B"
else
say "C"
end
6. Number Positive
set num to 5
if num > 0 then
say "Positive"
end
7. Even Odd
set num to 8
if num % 2 is 0 then
say "Even"
else
say "Odd"
end
8. AND Operator
set age to 22
set citizen to true
if age >= 18 and citizen is true then
say "Eligible"
end
9. OR Operator
set role to "Guest"
if role is "Admin" or role is "Guest" then
say "Access Granted"
end
10. Nested If
set age to 20
if age >= 18 then
if age >= 21 then
say "Can Vote and Drink"
else
say "sorry"
end
end
11. Switch Rank
set rank to "Guard"
switch rank then
case "Guard" then
say "Stand Watch"
default
say "Unknown"
end
12. Switch Day
set day to "Sunday"
switch day then
case "Sunday" then
say "Holiday"
default
say "Work Day"
end
13. Login Check
set user to "admin"
if user is "admin" then
say "Welcome Admin"
end
14. Goal Check
set gold to 500
if gold >= 500 then
say "Goal Achieved"
end
15. Complex Condition
set age to 25
set job to true
if age >= 18 and job is true then
say "Approved"
else
say "Rejected"
end