0% found this document useful (0 votes)
30 views3 pages

Python Flow Control Statements

The document outlines flow control statements in Python, which dictate the execution order of instructions. It covers conditional statements (if, if-else, if-elif-else), looping statements (for and while loops), and loop control statements (break, continue, pass) with examples. These constructs are essential for decision making and iteration in programming.

Uploaded by

Ravi N
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views3 pages

Python Flow Control Statements

The document outlines flow control statements in Python, which dictate the execution order of instructions. It covers conditional statements (if, if-else, if-elif-else), looping statements (for and while loops), and loop control statements (break, continue, pass) with examples. These constructs are essential for decision making and iteration in programming.

Uploaded by

Ravi N
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Operator Precedence in Python

Flow Control Statements in Python

Flow control statements determine the order in which instructions are executed in a program. Python

provides several flow control statements:

1. Conditional Statements (Decision Making):

Used to execute code based on conditions.

- if statement:

if condition:

# code block

- if-else statement:

if condition:

# code block

else:

# else block

- if-elif-else ladder:

if condition1:

# code block

elif condition2:

# code block

else:

# else block

Example:

age = 18

if age >= 18:

print("You are eligible to vote.")


Operator Precedence in Python

else:

print("You are not eligible.")

2. Looping Statements (Iteration):

Used to repeat a block of code multiple times.

- for loop:

for item in sequence:

# code block

- while loop:

while condition:

# code block

Example:

for i in range(5):

print(i) # Prints 0 to 4

count = 0

while count < 5:

print(count)

count += 1

3. Loop Control Statements:

Used to alter the behavior of loops.

- break: Exits the loop immediately.

- continue: Skips the current iteration and moves to the next.

- pass: Placeholder that does nothing (used when a statement is required syntactically).

Example:
Operator Precedence in Python

for i in range(5):

if i == 3:

break

print(i) # Prints 0, 1, 2

You might also like