输出九九乘法表
代码:
num1 = 1
while num1 <= 9:
num2 = 1
while num2 <= num1:
print(str(num2)+"*"+str(num1)+"="+str(num2*num1),end="\t")
num2 += 1
print()
num1 += 1
ps:“\t”为制表符;"\n"为换行。
执行结果:正序排列
代码修改:
num1 = 9
while num1 > 0:
num2 = 1
while num2 <= num1:
print(str(num2)+"*"+str(num1)+"="+str(num2*num1),end="\t")
num2 += 1
print()
num1 -= 1
执行结果:逆序排列