Python Statements

🧾 Python Statements

A statement in Python is a line of code that the Python interpreter can execute. Python programs are made up of many statements written line by line.

Examples of simple Python statements:

print("Hello")
x = 10

✔ Types of Python Statements

Python statements can be categorized as:

Type Example
Expression Statement x + 5, print(10)
Assignment Statement name = "Vipul"
Conditional Statement if, elif, else
Loop Statement for, while
Function Statement def greet():
Import Statement import math

✔ 1. Expression Statement

A statement where Python evaluates an expression.

10 + 20
print(5 * 2)

✔ 2. Assignment Statement

Used to assign values to variables.

x = 10
name = "Python"

Multiple assignment:

a, b, c = 10, 20, 30

✔ 3. Conditional Statements

Used to make decisions.

x = 20

if x > 10:
print("Greater than 10")


✔ 4. Loop Statements

Used to repeat actions.

for i in range(3):
print(i)
count = 1
while count <= 3:
print(count)
count += 1

✔ 5. Function Definition Statement

Defines reusable code.

def greet():
print("Hello!")

greet()


✔ 6. Import Statement

Used to include modules.

import math
print(math.sqrt(25))

🔹 Single-Line vs Multi-Line Statements

➤ Single-Line Statement

x = 5
print(x)

➤ Multiple Statements in One Line (Not Recommended)

a = 10; b = 20; print(a + b)

🔹 Line Continuation Statement

When a statement is long, use a backslash \.

result = 10 + 20 + 30 + \
40 + 50

🔹 Implicit Line Continuation (Inside (), [], {})

numbers = [
10, 20, 30,
40, 50
]

🎯 Summary Table

Concept Example
Simple statement print("Hello")
Multi-statement line x=1; y=2
Line continuation a = b + c \
Blocked statements if, for, while, def

CodeCapsule

Sanjit Sinha — Web Developer | PHP • Laravel • CodeIgniter • MySQL • Bootstrap Founder, CodeCapsule — Student projects & practical coding guides. Email: info@codecapsule.in • Website: CodeCapsule.in

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *