python学习之循环语句的九九乘法表
生活随笔
收集整理的這篇文章主要介紹了
python学习之循环语句的九九乘法表
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
while 語句的九九乘法表:
##九九乘法表
#總共有九行
# 每行中的列數,就是當前所處的行號
#乘式的第一個數代表的是列,第二個數代表的是行
row = 1
#行
column = 1
#列
while row <= 9:
while column <= row:
print('%d * %d = %d, '%(column,row,column * row),end='')
column += 1
print('') #換行
row += 1
column = 1
for 語句的九九乘法表:
for row in range (1,10):
for column in range(1,row +1):
print('%d * %d = %d, '%(column,row,column * row,),end="")
column +=1
print(' ')
row += 1
column = 1
?輸出結果如下:
?
轉載于:https://www.cnblogs.com/godblessmehaha/p/11043549.html
總結
以上是生活随笔為你收集整理的python学习之循环语句的九九乘法表的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 王者荣耀怎么修改实名认证?
- 下一篇: 电影《泰坦尼克号》的内容是?类似《泰坦尼