没有什么区别 只有print()变了 #三角星 ''' #while 循环 i = 1 while i <= 5: j = 1 while j<= i: print('*',end='') j += 1 i += 1 print() #for 循环 i = 1 for i in range(1,6): j = 1 #使j初值为1 for j in range(i): print('*',end='') j += 1 i += 1 print() #换行 ''' ''' #乘法表 while 循环 i = 1 while i <= 9: j = 1 while j <= i: print("%d*%d=%d" % (i, j, i * j), end='\t') j += 1 i += 1 print() ''' ''' for 循环 i = 1 for i in range(1,10): j = 1 for j in range(1,10): print("%d*%d=%d" % (i, j, i * j),end='\t') if i == j: print("") break print() '''
python 三角形和乘法表
最新推荐文章于 2024-05-10 09:24:43 发布