Page 91 - ThinkGPT_V2.1_C8_Flipbook
P. 91
code Quest Critical Thinking
1. Write the syntax of the for loop.
2. Write the syntax of the 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")
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
Program: To print first 12 whole numbers. Stop printing if number 7 is encountered.
Looping Statements in Python 89

