Chapter 11: Conditional Statements
Complete Python lesson for very beginners. Technical words are explained in simple language, and every outline topic includes a practical example, expected output, steps, and practice.
Chapter Overview
This Python tutorial chapter covers Conditional Statements through 15 connected topics. Work through the examples in order, check the expected output, and complete the practice after each topic.
- 11.1 Boolean Expressions
- 11.2 if
- 11.3 else
- 11.4 elif
- 11.5 Multiple Conditions
- Plus 10 additional Python topics in this chapter.
11.1 Boolean Expressions
Boolean Expressions is part of Conditional Statements. In simple language, it means a True or False value.
It is one building block of conditional statements and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
score = 82
if score >= 70:
print("pass")Expected Output
passStep-by-Step Explanation
- Create a condition.
- if runs its block only when the condition is truthy.
- Indent the controlled statement.
11.2 if
if is part of Conditional Statements. In simple language, it means a Python idea used while learning conditional statements.
It is one building block of conditional statements and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
score = 82
if score >= 70:
print("pass")Expected Output
passStep-by-Step Explanation
- Create a condition.
- if runs its block only when the condition is truthy.
- Indent the controlled statement.
11.3 else
else is part of Conditional Statements. In simple language, it means a Python idea used while learning conditional statements.
It is one building block of conditional statements and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
age = 15
if age >= 18:
print("adult")
else:
print("minor")Expected Output
minorStep-by-Step Explanation
- Test a condition.
- The condition is false.
- else runs the alternative block.
11.4 elif
elif is part of Conditional Statements. In simple language, it means a Python idea used while learning conditional statements.
It is one building block of conditional statements and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
score = 75
if score >= 90:
grade = "A"
elif score >= 70:
grade = "B"
else:
grade = "C"
print(grade)Expected Output
BStep-by-Step Explanation
- Check the first condition.
- elif checks another condition when earlier ones fail.
- Only one branch in this chain runs.
11.5 Multiple Conditions
Multiple Conditions is part of Conditional Statements. In simple language, it means a Python idea used while learning conditional statements.
It is one building block of conditional statements and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
value = 5
print("positive" if value > 0 else "not positive")Expected Output
positiveStep-by-Step Explanation
- Read the example from top to bottom.
- Identify the value, object, or operation related to this topic.
- Change one small input and predict the result before running it.
11.6 Nested Conditions
Nested Conditions is part of Conditional Statements. In simple language, it means a Python idea used while learning conditional statements.
It is one building block of conditional statements and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
value = 5
print("positive" if value > 0 else "not positive")Expected Output
positiveStep-by-Step Explanation
- Read the example from top to bottom.
- Identify the value, object, or operation related to this topic.
- Change one small input and predict the result before running it.
11.7 and
and is part of Conditional Statements. In simple language, it means a Python idea used while learning conditional statements.
It is one building block of conditional statements and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
age = 20
has_id = True
print(age >= 18 and has_id)
print(not has_id)Expected Output
True
FalseStep-by-Step Explanation
- Build boolean conditions.
- and requires both conditions to be true.
- not reverses a boolean value.
11.8 or
or is part of Conditional Statements. In simple language, it means a Python idea used while learning conditional statements.
It is one building block of conditional statements and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
age = 20
has_id = True
print(age >= 18 and has_id)
print(not has_id)Expected Output
True
FalseStep-by-Step Explanation
- Build boolean conditions.
- and requires both conditions to be true.
- not reverses a boolean value.
11.9 not
not is part of Conditional Statements. In simple language, it means a Python idea used while learning conditional statements.
It is one building block of conditional statements and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
age = 20
has_id = True
print(age >= 18 and has_id)
print(not has_id)Expected Output
True
FalseStep-by-Step Explanation
- Build boolean conditions.
- and requires both conditions to be true.
- not reverses a boolean value.
11.10 Truthy Values
Truthy Values is part of Conditional Statements. In simple language, it means a Python idea used while learning conditional statements.
It is one building block of conditional statements and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
values = [0, 1, "", "hello"]
for value in values:
print(bool(value))Expected Output
False
True
False
TrueStep-by-Step Explanation
- bool() shows truthiness.
- Zero and an empty string are falsy.
- Nonzero numbers and nonempty strings are truthy.
11.11 Falsy Values
Falsy Values is part of Conditional Statements. In simple language, it means a Python idea used while learning conditional statements.
It is one building block of conditional statements and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
values = [0, 1, "", "hello"]
for value in values:
print(bool(value))Expected Output
False
True
False
TrueStep-by-Step Explanation
- bool() shows truthiness.
- Zero and an empty string are falsy.
- Nonzero numbers and nonempty strings are truthy.
11.12 Conditional Expressions
Conditional Expressions is part of Conditional Statements. In simple language, it means a Python idea used while learning conditional statements.
It is one building block of conditional statements and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
score = 82
if score >= 70:
print("pass")Expected Output
passStep-by-Step Explanation
- Create a condition.
- if runs its block only when the condition is truthy.
- Indent the controlled statement.
11.13 Guard Conditions
Guard Conditions is part of Conditional Statements. In simple language, it means a Python idea used while learning conditional statements.
It is one building block of conditional statements and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
value = 5
print("positive" if value > 0 else "not positive")Expected Output
positiveStep-by-Step Explanation
- Read the example from top to bottom.
- Identify the value, object, or operation related to this topic.
- Change one small input and predict the result before running it.
11.14 Common Mistakes
Common Mistakes is part of Conditional Statements. In simple language, it means a Python idea used while learning conditional statements.
It is one building block of conditional statements and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
value = 5
print("positive" if value > 0 else "not positive")Expected Output
positiveStep-by-Step Explanation
- Read the example from top to bottom.
- Identify the value, object, or operation related to this topic.
- Change one small input and predict the result before running it.
11.15 Decision-Making Projects
Decision-Making Projects is part of Conditional Statements. In simple language, it means a Python idea used while learning conditional statements.
It is one building block of conditional statements and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
value = 5
print("positive" if value > 0 else "not positive")Expected Output
positiveStep-by-Step Explanation
- Read the example from top to bottom.
- Identify the value, object, or operation related to this topic.
- Change one small input and predict the result before running it.
Common Beginner Mistakes
- Copying code without predicting what each line does.
- Ignoring the first useful error message or traceback location.
- Mixing tabs/spaces or changing indentation accidentally.
- Using data of the wrong type for an operation.
- Trying to learn many advanced variations before mastering one small working example.
Chapter Practice
- Choose three topics from this chapter and re-type their examples without copying and pasting.
- For each example, change one input and predict the output first.
- Explain five technical terms from this chapter in your own beginner-friendly words.
- Create one small program that combines at least two chapter topics.
- Keep notes about errors you made and what fixed them.
Mini Project / Challenge
Create a small Python exercise that combines at least three ideas from Conditional Statements. Start with a tiny working version, test it, then improve it one step at a time.
- Choose three topics from this chapter.
- Write or adapt a small Python example using those topics.
- Predict the output before running the code.
- Test at least one different input.
- Write two sentences explaining what the program does and what you learned.
20 Questions & Answers
1. What is the main goal of Chapter 11?
The goal is to understand conditional statements through small explanations, examples, and practice.
2. Should I memorize every command or method?
No. Understand the pattern, practice the common form, and learn how to read documentation when you need exact details.
3. Why are the examples small?
Small examples isolate one idea at a time, which makes errors easier to understand and fix.
4. What should I do when an example gives an error?
Read the last part of the traceback, check spelling and indentation, confirm the required package or file exists, and compare the input types with what the operation expects.
5. Why should I predict output before running code?
Prediction forces you to reason about the program instead of only copying it.
6. What should I remember about Boolean Expressions?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.
7. What should I remember about if?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.
8. What should I remember about else?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.
9. What should I remember about elif?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.
10. What should I remember about Multiple Conditions?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.
11. What should I remember about Nested Conditions?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.
12. What should I remember about and?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.
13. What should I remember about or?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.
14. What should I remember about not?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.
15. What should I remember about Truthy Values?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.
16. What should I remember about Falsy Values?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.
17. What should I remember about Conditional Expressions?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.
18. What should I remember about Guard Conditions?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.
19. What should I remember about Common Mistakes?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.
20. What should I remember about Decision-Making Projects?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.