Ram

Lesson 4 of 19

Conditions

Use if, elif and else to make decisions.

Introduction

Conditional statements let a program choose what to do based on whether an expression is true or false.

Indentation is part of Python syntax, so keep code inside each branch aligned consistently.

Key insight

Use if, elif and else to make decisions.

Example

score = 82
if score >= 80:
    print("Great")
else:
    print("Keep practicing")

This example shows the core conditions idea in a small, runnable program.

Real-world example

Conditions appears in everyday application code, scripts and APIs.

Test yourself

2-question check

1

What is the main idea in Conditions?

2

Where can conditions be useful?

Ready to check your understanding?

Answer every question, then submit your quiz.

Try it yourself

Python compiler

Runs in your browser. Nothing is sent to a server.

Output appears here

First run downloads the Python runtime, so it may take a moment.

Practice challenge

Print 'Adult' when age is 18 or more, otherwise print 'Minor'.

Previous
Next