Page 105 - Code_GPT_Class_8
P. 105
Topic Flashback 21 st Century
Skills #Information Literacy
1. Write the syntax of for loop.
2. Write the syntax of while loop.
3. Write the output of the following:
a. for num in range(-10, 0, 1):
print(num)
b. count = 0
while (count < 5):
count = count + 1
print("Orange Education")
Hintbot
Factbot Any non-zero value or non-empty object
in the while loop condition indicates a
The else statement can be used with for True condition, whereas zero, None, or an
loop as well. empty object indicates a False condition.
THE JUMP STATEMENTS
Sometimes, there is a situation when the control of the program needs to be transferred out of the
loop body, even if all the values of the iterations of the loop have not been completed. For this purpose,
jump statements are used in Python. Python offers two jump statements—break and continue, which
are used within loops.
The break Statement
The break statement is used for exiting the program control out of the loop. The break statement
stops the execution of the loop and program flow continues to the statement after the loop. A single
break statement will break out of only one loop.
Syntax:
break
Loops in Python 103

