标签:i+1 python基础 print += int 乘法 range int() pre
‘‘‘
1 * 1 = 1
1 * 2 = 2 2 * 2 = 4
1 * 3 = 3 2 * 3 = 6 3 * 3 = 9
1 * 4 = 4 2 * 4 = 8 3 * 4 = 12 4 * 4 = 16
..................................................9 * 9 = 81
‘‘‘
#第一种方式
for i in range(1,10):
print() # 用来保证下面j的循环结束后,再次进入i循环时,输出回车,区分上下两行
for j in range(1,i+1):
print("{} * {} = {}".format(j,i,j * i),end="\t") #用来格式化输出上下两行
#第二种方式
m = 1
while m <= 9:
count = 1
while count <= m:
print(str(count) + ‘*‘ + str(m) + ‘=‘ + str(count * m),end=‘\t‘)
count += 1
m += 1
print()
标签:i+1 python基础 print += int 乘法 range int() pre
原文地址:https://blog.51cto.com/9237101/2440114