print("input the width and height")
height = int(input("input the height"))
width = int(input("input the width"))
flag = height
while width > 0:
while flag > 0:
print("#", end="")
flag -= 1
width -= 1
print("")
flag = height
要点:
- int() 强制类型转换为整型
- flag -= 1 自减1
print("output the 9*9 table")
flag = 1
for i in range(1, 10): #这个地方打印出的是数字1-9
j = flag
while j <= i:
print(j, "*", i, "=", j * i,end=" ") #注意设置不换行
j += 1
print("")
要点:
- range(1,10) 指定范围 可以想象成数组 存了1,2,3,4,5,6,7,8,9 。 1-9
- end=' ' 不换行设置
- j += 1 自加1