Page 628 - ComputerScience_Class_11
P. 628
The output of the preceding program is as follows:
Output
Guess the number between 1 and 100: 50
Too low!
Guess the number between 1 and 100: 70
Too high!
Guess the number between 1 and 100: 60
Too high!
Guess the number between 1 and 100: 55
Too high!
Guess the number between 1 and 100: 50
Too low!
Guess the number between 1 and 100: 52
Too high!
Guess the number between 1 and 100: 51
Congratulations, you guessed the correct number!
36. Write a program to print the following pattern:
*
***
*****
*******
*********
*******
*****
***
*
Program 36.py
File Edit Format Run Options Window Help
rows = int(input("Enter the number of rows for the upper half of the diamond: "))
for i in range(1, rows + 1):
print(' ' * (rows - i) + '*' * (2 * i - 1))
for i in range(rows - 1, 0, -1):
print(' ' * (rows - i) + '*' * (2 * i - 1))
The output of the preceding program is as follows:
Output
Enter the number of rows for the upper half of the diamond: 5
*
***
*****
*******
*********
*******
*****
***
*
626 Touchpad Computer Science (Ver. 3.0)-XI

