Page 108 - TP_Modular_V2.1_Class8
P. 108
"Imagine, you possess the power of 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 10: To add first five natural numbers.
Program10.py
File Edit Format Run Options Window Help
#Program to add first five natural numbers
sum = 0
a = 1
while (a <= 5):
sum += a
a += 1
print('The sum of first five natural number is', sum)
You will get the following output:
Output
The sum of first five natural number is 15
Program 11: To print the pattern of stars in decreasing order in the form of triangle.
**********
*********
********
*******
******
*****
****
*** Output
**
**********
*
*********
Program11.py ********
*******
File Edit Format Run Options Window Help ******
*****
#Program to create star pattern
****
***
for i in range(10, 0, -1):
**
print("*"*i) *
106 Modular (Ver. 2.1)-VIII

