0% found this document useful (0 votes)
68 views10 pages

Control Statements: Python Programming Sybsc (It) Sem-Iii 2020-21

The document discusses control statements in Python including break, continue, and pass. Break terminates the innermost loop and continues execution after the loop. Continue skips the rest of the current loop iteration and proceeds to the next one. Pass is used to construct an empty block that does nothing as a placeholder for future code.

Uploaded by

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

Control Statements: Python Programming Sybsc (It) Sem-Iii 2020-21

The document discusses control statements in Python including break, continue, and pass. Break terminates the innermost loop and continues execution after the loop. Continue skips the rest of the current loop iteration and proceeds to the next one. Pass is used to construct an empty block that does nothing as a placeholder for future code.

Uploaded by

Jayashree Borkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Control

statements
Python Programming

SYBSc(IT) SEM-III

2020-21
What Is This Topic About?

01 02

Terminating loops Skipping specifice conditions


Introduction
Control statements change execution from its normal sequence. Control statements
in python are used to control the flow of execution of the program based on the
specified conditions.

Python supports 3 types of control statements such as,


1) Break
2) Continue
3) Pass
Accept a number and check it is prime or not

Break
 The break statement in Python is
used to terminate a loop.
 This means whenever the interpreter
encounters the break keyword, it
simply exits out of the loop.
 If the break statement is used inside a
nested loop, it terminates the
innermost loop and the control shifts
to the next statement in the outer
loop.
 It is used in switch statement also to
terminate the case.
Continue
 Whenever the interpreter encounters
a continue statement in Python, it will
skip the execution of the rest of the
statements in that loop and proceed
with the next iteration.
 This means it returns the control to
the beginning of the loop.
 Unlike the break statement, continue
statement does not terminate or exit
out of the loop.
 Rather, it continues with the next
iteration
Pass
 Assume we have a loop that is not
implemented yet but needs to
implemented in the future.
 In this case, if you leave the loop
empty, the interpreter will throw an
error.
 To avoid this, you can use the pass
statement to construct a block that
does nothing i.e contains no
statements.
 It is a placeholder for future code
 It is null block
Questions
1) How many control statements are present in Python?
In Python, there are 3 types of control statements. Namely, break, continue and pass statements.

2) How to break from a loop in Python?


The keyword break is used to break or terminate from the current loop. The control shifts to the
next statement outside the loop.

3) What is the difference between break and continue statements in Python?


Break statement exits out of the loop, but the continue statement shifts the control to the next
iteration and doesn’t exit out of the loop.

4) Can we use continue in if statement in Python?


Yes. Continue statements can be used within an if statement.

5) What is the use of pass keyword in Python?


Pass keyword helps in avoiding errors that result due to an empty loop.
Thank
You

You might also like