用 while ……while 双层while 做9*9乘法表

lint=1  #第一个行值赋值为1
while lint <=9:#判断第一个行值是否小于9
    temp =1#再重新把第一个列值赋值为1
    while temp <=lint:#判断列值是否小于行值
        print((temp),"*",(lint),"=",(temp*lint),end="\t")#行值*列值=行、列的乘积
        temp +=1#列值递增1
    print()#输出一个换行
    lint +=1#行值递增1

猜你喜欢

转载自www.cnblogs.com/mouni-11498/p/9205583.html