Python学习日记-4-while循环输出矩形,三角形
程序员文章站
2024-02-21 18:54:46
...
利用两个while相嵌套,输出由#组成的任意长宽矩形和三角形
height = int(input("Pleaes input the heigut:"))
width = int(input("Pleaes input the width:"))
num_height = height
num_width = width
while num_height >= 1:
num_width = width
while num_width >= 1:
print("#",end="")
num_width-=1
print()
num_height-=1
height = int(input("Pleaes input the heigut:"))
num_height = 1
num_width = 1
while num_height <= height:
num_width = 1
while num_width <= num_height:
print("#",end=" ")
num_width += 1
num_height += 1
print()
上一篇: HDFS安装