Page 151 - TP_Plus_v2.2_Class_8
P. 151
Let’s CatCh uP Factopedia
What will be the output of the given Python code?
i = 0
while (i == 0): print(“Hello Touchpad”)
________________________________________________________
21 st
Let’s PraCtiCe Century #Technology Literacy Python is the only
Skills
language which uses
Write a program in Python to find whether the given number is else statement with
prime or not. the loops.
______________________________________________________
______________________________________________________
Let’s BaCk-uP
Looping statements are very useful and necessary for Some of the
developing applications. companies like
Python provides two types of looping statements—for and while. NASA , Netflix ,
The for statement executes a simple or compound statement Google ,
for a fixed number of times. Amazon ,
The range() function is an in-built function of Python. YouTube ,
A sequence is a succession of values bound together by a Spotify ,
single name. Dropbox , etc.
The while statement executes a set of statements repeatedly, use (or have used)
until the logical expression evaluates to true. Python for their
The else block is executed when the condition given in the products/services.
while statement becomes false.
To come out of the infinite loop, we can either close the
program window or press Ctrl + C.
The break is a keyword in Python which is used for bringing
the program control out of the loop.
When a continue statement is encountered inside a loop,
control of the program jumps to the beginning of the loop for
next iteration, skipping the execution of rest of the statements Python does not have
of the loop. do-while loop.
Loops in Python 149

