99乘法表 嵌套循环
9*9乘法表的实现:
cmd界面截图:

源码:
#打印9*9乘法表
row = 1
while row <= 9:
column =1
while column <= row:
print(str(row)+"*"+str(column)+"="+str(row*column)+" ",end="")
column+=1
print()
row+=1
print()
疑问:
print(str(row)+"*"+str(column)+"="+str(row*column)+" ",end="")打印结果随此行代码的不同而显示不同,路上图所示。
第一种形式:print(row,"*",column,"=",row*column," ",end="");
第二种形式:print(str(row),"*",str(column),"=",str(row*column)," ",end="");
第三种形式:print(str(row)+"*"+str(column)+"="+str(row*column)+" ",end="")。
复习回顾解决问题:解决占位符的python准则。

浙公网安备 33010602011771号