乘法表的while2种方法,还有for的没写

以下是代码

#!/usr/bin/env python3
# -*- conding:utf-8 -*-
# @Time: 2017/12/10 19:11
# @Author:Luke
#打印乘法表
i = 1
'''
while i <= 9:
for j in range(9):
j += 1
if j == 9 and i != 9:
print("\n")
elif j > i :
continue
else:
print("%d * %d = %d " % ( i , j ,i * j ),end=" ")
i += 1
'''
#这种方法更简便
while i <= 9:
j = 1
while j <= i :
x = i * j
print("%d * %d = %d "%(j,i,x),end=" ")
j += 1
print("")
i += 1
欢迎探讨问题
posted @ 2017-12-10 20:16  煜轩  阅读(161)  评论(0编辑  收藏  举报