网络编程
位置:首页>> 网络编程>> Python编程>> Python使用while循环花式打印乘法表

Python使用while循环花式打印乘法表

作者:Mr.o.j  发布时间:2021-02-23 21:38:40 

标签:python,while循环,乘法表

花式打印9*9乘法表


#第一个计数器
i = 1
while i < 10:
 #第二个计数器
 j = 1
 while j <= i:
   print('%d*%d=%d\t' %(j, i, i*j) , end=(''))
   j +=1
 #换行
 print('')
 i +=1
#输出换行
print('')

Python使用while循环花式打印乘法表


i = 1
while i <= 9:
 k = 8
 j = 1
 while k >= i:
   print('\t\t', end=(''))
   k -= 1
 while j <= i:
   print('%d*%d=%d\t' % (j, i, i * j), end=(''))
   j += 1
 print('')
 i += 1
print('')

Python使用while循环花式打印乘法表


i = 9
while i > 0:
 j = 1
 k = 8
 while k >= i:
   print('\t\t', end=(''))
   k -= 1
 while j <= i:
   print('%d*%d=%d\t' % (j, i, j * i), end=(''))
   j += 1
 print('')
 i -= 1
print('')

Python使用while循环花式打印乘法表

来源:https://blog.csdn.net/weixin_40543283/article/details/86572611

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com