Page 109 - TP_Play_V2.2_Class8
P. 109
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) *
NASA’s reusable space shuttle in the 1970s had less code than our phones today.
#Loops in Python 107

