## 六.while循环嵌套应用
---
### 6.1应用一:打印星号(正方形)
---
6.1.1需求
```python
*****
*****
*****
*****
*****
```
6.1.2代码
```python
j = 0
while j < 5:
i = 0
while i < 5:
print('*',end='')
i += 1
print('\n')
j += 1
```
### 6.2.1 应用二:打印星号(三角形)
----
6.2.1需求
```python
*
**
***
****
*****
```
6.2.2代码
- 分析:一行输出星星的个数和星号是相等的,每行的:重复打印行号数字个星号,将打印星号的命令重复执行5次实现打印5行。
```python
j = 1
while j <= 5:
i = 1
while i <= j:
print('*',end='')
i += 1
print('')
j += 1
```
### 6.3 九九乘法表
---
6.3.1代码
```python
j = 1
while j <= 9:
i = 1
while i <= j:
print(f'{j}*{i}={j*i}',end='\t') # 制表符 制表位
i += 1
print()
j += 1
```