日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Python程序:打印乘法表

創(chuàng)新互聯(lián)python教程:

寫一個 Python 程序,用 For 循環(huán)和 While 循環(huán)打印乘法表,并舉例說明。

用 For 循環(huán)打印乘法表的 Python 程序

這個 Python 程序使用 For 循環(huán)顯示從 8 到 10 的乘法表。

print(" Multiplication Table ")

for i in range(8, 10):
    for j in range(1, 11):
        print('{0}  *  {1}  =  {2}'.format(i, j, i*j))
    print('==============')

Python 乘法表輸出

 Multiplication Table 
8  *  1  =  8
8  *  2  =  16
8  *  3  =  24
8  *  4  =  32
8  *  5  =  40
8  *  6  =  48
8  *  7  =  56
8  *  8  =  64
8  *  9  =  72
8  *  10  =  80
==============
9  *  1  =  9
9  *  2  =  18
9  *  3  =  27
9  *  4  =  36
9  *  5  =  45
9  *  6  =  54
9  *  7  =  63
9  *  8  =  72
9  *  9  =  81
9  *  10  =  90
==============

顯示乘法表的 Python 程序示例 2

這個 Python 程序允許用戶輸入任意整數(shù)值。接下來, For Loop 中的打印功能將用戶輸入值的乘法表打印到 10。

num = int(input(" Please Enter any Positive Integer lessthan 10 : "))

print(" Multiplication Table ")

for i in range(num, 10):
    for j in range(1, 11):
        print('{0}  *  {1}  =  {2}'.format(i, j, i*j))
    print('==============')

使用 While 循環(huán)顯示乘法表的 Python 程序

這個 Python 乘法表程序同上。但是這次,我們使用的是 While Loop 。

i = int(input(" Please Enter any Positive Integer lessthan 10 : "))

print(" Multiplication Table ")

while(i <= 10):
    j = 1
    while(j <= 10):
        print('{0}  *  {1}  =  {2}'.format(i, j, i*j))
        j = j + 1
    print('==============')
    i = i + 1
 Please Enter any Positive Integer lessthan 10 : 8
 Multiplication Table 
8  *  1  =  8
8  *  2  =  16
8  *  3  =  24
8  *  4  =  32
8  *  5  =  40
8  *  6  =  48
8  *  7  =  56
8  *  8  =  64
8  *  9  =  72
8  *  10  =  80
==============
9  *  1  =  9
9  *  2  =  18
9  *  3  =  27
9  *  4  =  36
9  *  5  =  45
9  *  6  =  54
9  *  7  =  63
9  *  8  =  72
9  *  9  =  81
9  *  10  =  90
==============
10  *  1  =  10
10  *  2  =  20
10  *  3  =  30
10  *  4  =  40
10  *  5  =  50
10  *  6  =  60
10  *  7  =  70
10  *  8  =  80
10  *  9  =  90
10  *  10  =  100
==============

網(wǎng)頁題目:Python程序:打印乘法表
標題URL:http://m.5511xx.com/article/dpjchgp.html