+91 81900 98289

Python Statements

This Python Statements lesson is for a beginner. Read the short notes, run each example, then change one name or number and run it again.

A statement is one instruction. Python runs the statements in a file from top to bottom.

An assignment, a call to print, and a return are statements. An if, for, or def is a compound statement: it ends with a colon and owns the indented lines under it.

Example 1: Start here

A block cannot be empty. Use pass when the body is not written yet.

city = "Chennai" # text print(city)

Example 2: Three statements in order

Python runs the file from the top. The print happens after both names exist.

city = "Chennai" # text seats = 24 # a whole number print(city, seats) # a comma prints each value, with a space between

Example 3: A statement on one line

Each line is one statement. They run in the order you wrote them.

print("one") # print writes this; the quotes are not shown print("two")

Example 4: Use pass as a placeholder

pass is an empty statement. The program continues after the block.

ready = False # True or False, not text if not ready: # run the indented lines only when this is true pass # a placeholder, so the block is not empty print("still going")
A block cannot be empty. Use pass when the body is not written yet.
Call Now 81900 98289