1. 打印等边三角形,代码:
equilateral_triangle_height = int(input('Please input an odd number (triangle height): '))
for i in range(equilateral_triangle_height, 0, -1):
print(i*' '+(equilateral_triangle_height-i+1)*'* ')
结果:
2. 打印九九乘法表,代码:
for i in range(1,10):
for j in range(1, i+1):
print(f'{j} x {i} = {i*j}', end="\t")
print()
结果: