EASYTUTORGUIDE

Practical tutorials, tools, courses, digital skills, and business promotion.

Free Learning

JavaScript – Chapter 2: Development Environment

Learn what JavaScript is, where it runs, why it is important, and how beginners can start using it with simple examples and clear output.

Beginner Friendly JavaScript Basics Web Development Code Examples
JavaScript Lesson 2 Chapter 2 Topics Day / Night Mode

Main reading content

python-course-chapter-11

Chapter 11: Conditional Statements

Learn how Python makes decisions with conditions, Boolean expressions, if statements, and match-case patterns.

Goal: Build clear decision-making programs that respond correctly to different values and user choices.

Chapter 11 Topics

11.1 Introduction to Decision Making

Introduction to Decision Making is an important part of Python conditional programming. It helps a program examine information and decide which instructions should run. Beginners should read the condition carefully, notice the colon, and keep the related code indented. This topic is commonly used in forms, menus, games, validation, calculations, and everyday decision-making programs.

Example

age = 20
if age >= 18:
    print("Adult")

Output

Adult

Output explanation: Python checks the condition or pattern from top to bottom. The matching or true branch runs, producing the output shown above. Lines belonging to the selected block are indented, while blocks whose conditions are false are skipped.

11.2 Boolean Expressions

Boolean Expressions is an important part of Python conditional programming. It helps a program examine information and decide which instructions should run. Beginners should read the condition carefully, notice the colon, and keep the related code indented. This topic is commonly used in forms, menus, games, validation, calculations, and everyday decision-making programs.

Example

age = 20
if age >= 18:
    print("Adult")

Output

Adult

Output explanation: Python checks the condition or pattern from top to bottom. The matching or true branch runs, producing the output shown above. Lines belonging to the selected block are indented, while blocks whose conditions are false are skipped.

11.3 The if Statement

The if Statement is an important part of Python conditional programming. It helps a program examine information and decide which instructions should run. Beginners should read the condition carefully, notice the colon, and keep the related code indented. This topic is commonly used in forms, menus, games, validation, calculations, and everyday decision-making programs.

Example

age = 20
if age >= 18:
    print("Adult")

Output

Adult

Output explanation: Python checks the condition or pattern from top to bottom. The matching or true branch runs, producing the output shown above. Lines belonging to the selected block are indented, while blocks whose conditions are false are skipped.

11.4 The else Statement

The else Statement is an important part of Python conditional programming. It helps a program examine information and decide which instructions should run. Beginners should read the condition carefully, notice the colon, and keep the related code indented. This topic is commonly used in forms, menus, games, validation, calculations, and everyday decision-making programs.

Example

age = 15
if age >= 18:
    print("Adult")
else:
    print("Minor")

Output

Minor

Output explanation: Python checks the condition or pattern from top to bottom. The matching or true branch runs, producing the output shown above. Lines belonging to the selected block are indented, while blocks whose conditions are false are skipped.

11.5 The elif Statement

The elif Statement is an important part of Python conditional programming. It helps a program examine information and decide which instructions should run. Beginners should read the condition carefully, notice the colon, and keep the related code indented. This topic is commonly used in forms, menus, games, validation, calculations, and everyday decision-making programs.

Example

score = 75
if score >= 90:
    print("A")
elif score >= 70:
    print("B")
else:
    print("C")

Output

B

Output explanation: Python checks the condition or pattern from top to bottom. The matching or true branch runs, producing the output shown above. Lines belonging to the selected block are indented, while blocks whose conditions are false are skipped.

11.6 Multiple Conditions

Multiple Conditions is an important part of Python conditional programming. It helps a program examine information and decide which instructions should run. Beginners should read the condition carefully, notice the colon, and keep the related code indented. This topic is commonly used in forms, menus, games, validation, calculations, and everyday decision-making programs.

Example

age = 20
if age >= 18:
    print("Adult")

Output

Adult

Output explanation: Python checks the condition or pattern from top to bottom. The matching or true branch runs, producing the output shown above. Lines belonging to the selected block are indented, while blocks whose conditions are false are skipped.

11.7 Nested Conditions

Nested Conditions is an important part of Python conditional programming. It helps a program examine information and decide which instructions should run. Beginners should read the condition carefully, notice the colon, and keep the related code indented. This topic is commonly used in forms, menus, games, validation, calculations, and everyday decision-making programs.

Example

age = 20
if age >= 18:
    print("Adult")

Output

Adult

Output explanation: Python checks the condition or pattern from top to bottom. The matching or true branch runs, producing the output shown above. Lines belonging to the selected block are indented, while blocks whose conditions are false are skipped.

11.8 Comparison Operators

Comparison Operators is an important part of Python conditional programming. It helps a program examine information and decide which instructions should run. Beginners should read the condition carefully, notice the colon, and keep the related code indented. This topic is commonly used in forms, menus, games, validation, calculations, and everyday decision-making programs.

Example

age = 20
if age >= 18:
    print("Adult")

Output

Adult

Output explanation: Python checks the condition or pattern from top to bottom. The matching or true branch runs, producing the output shown above. Lines belonging to the selected block are indented, while blocks whose conditions are false are skipped.

11.9 Logical Operators

Logical Operators is an important part of Python conditional programming. It helps a program examine information and decide which instructions should run. Beginners should read the condition carefully, notice the colon, and keep the related code indented. This topic is commonly used in forms, menus, games, validation, calculations, and everyday decision-making programs.

Example

age = 20
if age >= 18:
    print("Adult")

Output

Adult

Output explanation: Python checks the condition or pattern from top to bottom. The matching or true branch runs, producing the output shown above. Lines belonging to the selected block are indented, while blocks whose conditions are false are skipped.

11.10 Membership Conditions

Membership Conditions is an important part of Python conditional programming. It helps a program examine information and decide which instructions should run. Beginners should read the condition carefully, notice the colon, and keep the related code indented. This topic is commonly used in forms, menus, games, validation, calculations, and everyday decision-making programs.

Example

age = 20
if age >= 18:
    print("Adult")

Output

Adult

Output explanation: Python checks the condition or pattern from top to bottom. The matching or true branch runs, producing the output shown above. Lines belonging to the selected block are indented, while blocks whose conditions are false are skipped.

11.11 Identity Conditions

Identity Conditions is an important part of Python conditional programming. It helps a program examine information and decide which instructions should run. Beginners should read the condition carefully, notice the colon, and keep the related code indented. This topic is commonly used in forms, menus, games, validation, calculations, and everyday decision-making programs.

Example

age = 20
if age >= 18:
    print("Adult")

Output

Adult

Output explanation: Python checks the condition or pattern from top to bottom. The matching or true branch runs, producing the output shown above. Lines belonging to the selected block are indented, while blocks whose conditions are false are skipped.

11.12 Truthy Values

Truthy Values is an important part of Python conditional programming. It helps a program examine information and decide which instructions should run. Beginners should read the condition carefully, notice the colon, and keep the related code indented. This topic is commonly used in forms, menus, games, validation, calculations, and everyday decision-making programs.

Example

age = 20
if age >= 18:
    print("Adult")

Output

Adult

Output explanation: Python checks the condition or pattern from top to bottom. The matching or true branch runs, producing the output shown above. Lines belonging to the selected block are indented, while blocks whose conditions are false are skipped.

11.13 Falsy Values

Falsy Values is an important part of Python conditional programming. It helps a program examine information and decide which instructions should run. Beginners should read the condition carefully, notice the colon, and keep the related code indented. This topic is commonly used in forms, menus, games, validation, calculations, and everyday decision-making programs.

Example

age = 20
if age >= 18:
    print("Adult")

Output

Adult

Output explanation: Python checks the condition or pattern from top to bottom. The matching or true branch runs, producing the output shown above. Lines belonging to the selected block are indented, while blocks whose conditions are false are skipped.

11.14 Short-Form if Statements

Short-Form if Statements is an important part of Python conditional programming. It helps a program examine information and decide which instructions should run. Beginners should read the condition carefully, notice the colon, and keep the related code indented. This topic is commonly used in forms, menus, games, validation, calculations, and everyday decision-making programs.

Example

age = 20
if age >= 18:
    print("Adult")

Output

Adult

Output explanation: Python checks the condition or pattern from top to bottom. The matching or true branch runs, producing the output shown above. Lines belonging to the selected block are indented, while blocks whose conditions are false are skipped.

11.15 Conditional Expressions

Conditional Expressions is an important part of Python conditional programming. It helps a program examine information and decide which instructions should run. Beginners should read the condition carefully, notice the colon, and keep the related code indented. This topic is commonly used in forms, menus, games, validation, calculations, and everyday decision-making programs.

Example

age = 20
if age >= 18:
    print("Adult")

Output

Adult

Output explanation: Python checks the condition or pattern from top to bottom. The matching or true branch runs, producing the output shown above. Lines belonging to the selected block are indented, while blocks whose conditions are false are skipped.

11.16 Ternary Operators

Ternary Operators is an important part of Python conditional programming. It helps a program examine information and decide which instructions should run. Beginners should read the condition carefully, notice the colon, and keep the related code indented. This topic is commonly used in forms, menus, games, validation, calculations, and everyday decision-making programs.

Example

age = 20
if age >= 18:
    print("Adult")

Output

Adult

Output explanation: Python checks the condition or pattern from top to bottom. The matching or true branch runs, producing the output shown above. Lines belonging to the selected block are indented, while blocks whose conditions are false are skipped.

11.17 The pass Statement

The pass Statement is an important part of Python conditional programming. It helps a program examine information and decide which instructions should run. Beginners should read the condition carefully, notice the colon, and keep the related code indented. This topic is commonly used in forms, menus, games, validation, calculations, and everyday decision-making programs.

Example

age = 20
if age >= 18:
    print("Adult")

Output

Adult

Output explanation: Python checks the condition or pattern from top to bottom. The matching or true branch runs, producing the output shown above. Lines belonging to the selected block are indented, while blocks whose conditions are false are skipped.

11.18 Match-Case Statements

Match-Case Statements is an important part of Python conditional programming. It helps a program examine information and decide which instructions should run. Beginners should read the condition carefully, notice the colon, and keep the related code indented. This topic is commonly used in forms, menus, games, validation, calculations, and everyday decision-making programs.

Example

day = 2
match day:
    case 1:
        print("Monday")
    case 2:
        print("Tuesday")
    case _:
        print("Unknown")

Output

Tuesday

Output explanation: Python checks the condition or pattern from top to bottom. The matching or true branch runs, producing the output shown above. Lines belonging to the selected block are indented, while blocks whose conditions are false are skipped.

11.19 Match Patterns

Match Patterns is an important part of Python conditional programming. It helps a program examine information and decide which instructions should run. Beginners should read the condition carefully, notice the colon, and keep the related code indented. This topic is commonly used in forms, menus, games, validation, calculations, and everyday decision-making programs.

Example

age = 20
if age >= 18:
    print("Adult")

Output

Adult

Output explanation: Python checks the condition or pattern from top to bottom. The matching or true branch runs, producing the output shown above. Lines belonging to the selected block are indented, while blocks whose conditions are false are skipped.

11.20 OR Patterns

OR Patterns is an important part of Python conditional programming. It helps a program examine information and decide which instructions should run. Beginners should read the condition carefully, notice the colon, and keep the related code indented. This topic is commonly used in forms, menus, games, validation, calculations, and everyday decision-making programs.

Example

age = 20
if age >= 18:
    print("Adult")

Output

Adult

Output explanation: Python checks the condition or pattern from top to bottom. The matching or true branch runs, producing the output shown above. Lines belonging to the selected block are indented, while blocks whose conditions are false are skipped.

11.21 Capture Patterns

Capture Patterns is an important part of Python conditional programming. It helps a program examine information and decide which instructions should run. Beginners should read the condition carefully, notice the colon, and keep the related code indented. This topic is commonly used in forms, menus, games, validation, calculations, and everyday decision-making programs.

Example

age = 20
if age >= 18:
    print("Adult")

Output

Adult

Output explanation: Python checks the condition or pattern from top to bottom. The matching or true branch runs, producing the output shown above. Lines belonging to the selected block are indented, while blocks whose conditions are false are skipped.

11.22 Wildcard Patterns

Wildcard Patterns is an important part of Python conditional programming. It helps a program examine information and decide which instructions should run. Beginners should read the condition carefully, notice the colon, and keep the related code indented. This topic is commonly used in forms, menus, games, validation, calculations, and everyday decision-making programs.

Example

age = 20
if age >= 18:
    print("Adult")

Output

Adult

Output explanation: Python checks the condition or pattern from top to bottom. The matching or true branch runs, producing the output shown above. Lines belonging to the selected block are indented, while blocks whose conditions are false are skipped.

11.23 Guard Conditions

Guard Conditions is an important part of Python conditional programming. It helps a program examine information and decide which instructions should run. Beginners should read the condition carefully, notice the colon, and keep the related code indented. This topic is commonly used in forms, menus, games, validation, calculations, and everyday decision-making programs.

Example

age = 20
if age >= 18:
    print("Adult")

Output

Adult

Output explanation: Python checks the condition or pattern from top to bottom. The matching or true branch runs, producing the output shown above. Lines belonging to the selected block are indented, while blocks whose conditions are false are skipped.

11.24 Nested Match Patterns

Nested Match Patterns is an important part of Python conditional programming. It helps a program examine information and decide which instructions should run. Beginners should read the condition carefully, notice the colon, and keep the related code indented. This topic is commonly used in forms, menus, games, validation, calculations, and everyday decision-making programs.

Example

age = 20
if age >= 18:
    print("Adult")

Output

Adult

Output explanation: Python checks the condition or pattern from top to bottom. The matching or true branch runs, producing the output shown above. Lines belonging to the selected block are indented, while blocks whose conditions are false are skipped.

11.25 Input Validation

Input Validation is an important part of Python conditional programming. It helps a program examine information and decide which instructions should run. Beginners should read the condition carefully, notice the colon, and keep the related code indented. This topic is commonly used in forms, menus, games, validation, calculations, and everyday decision-making programs.

Example

age = 20
if age >= 18:
    print("Adult")

Output

Adult

Output explanation: Python checks the condition or pattern from top to bottom. The matching or true branch runs, producing the output shown above. Lines belonging to the selected block are indented, while blocks whose conditions are false are skipped.

11.26 Real-World Decision Systems

Real-World Decision Systems is an important part of Python conditional programming. It helps a program examine information and decide which instructions should run. Beginners should read the condition carefully, notice the colon, and keep the related code indented. This topic is commonly used in forms, menus, games, validation, calculations, and everyday decision-making programs.

Example

age = 20
if age >= 18:
    print("Adult")

Output

Adult

Output explanation: Python checks the condition or pattern from top to bottom. The matching or true branch runs, producing the output shown above. Lines belonging to the selected block are indented, while blocks whose conditions are false are skipped.

11.27 Chapter Practice Exercises

Chapter Practice Exercises is an important part of Python conditional programming. It helps a program examine information and decide which instructions should run. Beginners should read the condition carefully, notice the colon, and keep the related code indented. This topic is commonly used in forms, menus, games, validation, calculations, and everyday decision-making programs.

Example

number = 8
print("Even" if number % 2 == 0 else "Odd")

Output

Even

Output explanation: Python checks the condition or pattern from top to bottom. The matching or true branch runs, producing the output shown above. Lines belonging to the selected block are indented, while blocks whose conditions are false are skipped.

11.28 Chapter Mini Project

Chapter Mini Project is an important part of Python conditional programming. It helps a program examine information and decide which instructions should run. Beginners should read the condition carefully, notice the colon, and keep the related code indented. This topic is commonly used in forms, menus, games, validation, calculations, and everyday decision-making programs.

Example

balance = 120
price = 50
if balance >= price:
    balance -= price
    print("Purchase approved")
    print("Balance:", balance)
else:
    print("Not enough money")

Output

Purchase approved
Balance: 70

Output explanation: Python checks the condition or pattern from top to bottom. The matching or true branch runs, producing the output shown above. Lines belonging to the selected block are indented, while blocks whose conditions are false are skipped.

Chapter 2: Development EnvironmentPrepare Your JavaScript Workspace

A modern course built to help learners study step by step with clarity, comfort, and confidence.