Introduction to Python
Form 3 - Computer
2023-2024
Floor 4 - Computer Room
Mr. Peter
Outline
Outline
While Loop
![](https://s3.amazonaws.com/media-p.slid.es/uploads/2214875/images/9811262/pasted-from-clipboard.png)
1
Number Sequences
2
Exercises
3
While Loop Statement
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1490014/images/9343467/pasted-from-clipboard.png)
1.
2.
Tab
while Condition :
Command1
![](https://s3.amazonaws.com/media-p.slid.es/uploads/2214875/images/10437733/pasted-from-clipboard.png)
While Loop Statement
1.
2.
while i < 5 :
3.
Tab
4.
Tab
i = 0
print(i)
i = i + 1
Write a Python program that prints an inverted half pyramid of stars with a fixed number of rows, n = 10.
Question
While loop statement - Ex01
Example
Save the file as "XX_YYYY_Ex01.py"
**********
*********
********
*******
******
*****
****
***
**
*
Write a Python program that prints an equilateral triangle pattern of stars with a fixed number of 10 rows.
Question
While loop statement - Ex02
Example
Save the file as "XX_YYYY_Ex02.py"
*
***
*****
*******
*********
***********
*************
***************
*****************
*******************
Write a Python program that prints a hollow rectangle pattern of stars. The program should use variables width and height to control the dimensions of the rectangle.
Question
While loop statement - Ex03
Example, if width = 10 and height = 5
Save the file as "XX_YYYY_Ex03.py"
**********
* *
* *
* *
**********
Write a Python program that prints a hollow right-angled triangle pattern of stars with a fixed size of 10 lines.
Question
While loop statement - Ex04
Example, if width = 10 and height = 5
Save the file as "XX_YYYY_Ex04.py"
*
**
* *
* *
* *
* *
* *
* *
* *
**********
Python - While Loop 05
By Mr Peter
Python - While Loop 05
- 176