
Some Beginner-friendly Python programs for all the common decision-making statements.
1. if Statement
Checks a condition. If it is true, the code runs.
age = 18
if age >= 18:
print("You are eligible to vote.")
Output:
You are eligible to vote.
2. if…else Statement
If the condition is true, one block runs. Otherwise, another block runs.
number = 7
if number % 2 == 0:
print("Even number")
else:
print("Odd number")
Output:
Odd number
3. if…elif…else Statement
Checks multiple conditions one by one.
marks = 78
if marks >= 90:
print("Grade A")
elif marks >= 75:
print("Grade B")
elif marks >= 50:
print("Grade C")
else:
print("Fail")
Output:
Grade B
4. Nested if
An if statement inside another if statement.
age = 22
has_id = True
if age >= 18:
if has_id:
print("Entry allowed.")
Output:
Entry allowed.
5. Using and
Both conditions must be true.
age = 20
citizen = True
if age >= 18 and citizen:
print("You can vote.")
Output:
You can vote.
6. Using or
At least one condition must be true.
day = "Sunday"
if day == "Saturday" or day == "Sunday":
print("It's the weekend!")
Output:
It's the weekend!
7. Using not
Reverses a condition.
logged_in = False
if not logged_in:
print("Please log in.")
Output:
Please log in.
8. Short-Hand if
A single-line if statement.
age = 20
if age >= 18: print("Adult")
Output:
Adult
9. Short-Hand if…else (Ternary Operator)
Writes if...else in one line.
age = 15 status = "Adult" if age >= 18 else "Minor" print(status)
Output:
Minor
10. Multiple Conditions with and and or
temperature = 30
is_sunny = True
if temperature > 25 and is_sunny:
print("A great day for a picnic!")
else:
print("Better stay indoors.")
Output:
A great day for a picnic!
11. Comparing Strings
password = "python123"
if password == "python123":
print("Access Granted")
else:
print("Wrong Password")
Output:
Access Granted
12. Comparing User Input
age = int(input("Enter your age: "))
if age >= 18:
print("You are an adult.")
else:
print("You are a minor.")
Sample Output
Enter your age: 16 You are a minor.
Try to write your own programs using these DECISION MAKING STATEMENTS in Python and I am sure you would have learned a lot!!