Page 89 - Dig_CodeAI_V2.1_Class_8
P. 89
On running the above program, you will get the following output:
Imagine you possess the power of the jump statement, allowing you to leap to any
part of the universe. Where would you jump to, and what quests or missions would
you undertake in each dimension?
Program: To print a pattern using for loop.
*
**
***
****
*****
******
*******
********
*********
The while Loop
The while loop executes a set of statements repeatedly, until the logical expression evaluates to
false. When the condition becomes false, the control comes out of the loop. The syntax of while
statement is given below:
On running the above program, you will get the following output: while (test expression):
Statements
increment/decrement expression
Program: To print first 5 natural numbers using while loop.
On running the above program, you will get the following output:
Program: To print multiplication table of number taken as input from user.
Looping Statements in Python 87

