與小卡特一起學python 第8章 動手試一試原始碼

yarking207發表於2016-04-01
#與小卡特一起學python 8章動手試一試原始碼
#8.1 編寫一個程式,顯示乘法表,開始時候詢問使用者顯示哪個數的乘法表
##import easygui
##looper = easygui.integerbox("Which multiplication table would you like?")
looper = int(input("Which multiplication table would you like?\n"))
print("Here's your table:")
for i in range(1,11):
    print(looper ,"x",i,"=",looper * i)


#8.2 用例子1中題目試著用while迴圈完成
looper =int(input("Which multiplication table would you like?\n"))
print("Here's your table:")
i=1
while i<11:
    print (looper,"x",i,"=",i*looper)
    i=i+1
#8.3 向乘法數中加點互動,問希望乘到最大是幾?
looper =int(input("Which multiplication table would you like?\n"))
lager =int(input("How high do you want to go?\n"))
i=1
print("Here's your table:")
##while i <=lager:
##    print(looper,"x",i,looper*i)
##    i=i+1
for i in range(1,lager+1):  #range()要加1
    print(looper,"x",i,looper*i)

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/220205/viewspace-2073994/,如需轉載,請註明出處,否則將追究法律責任。

相關文章