請看示例:
一行實現99乘法表:
print('\n'.join(['
'.join(['
%s*%s=%-2s
' % (y, x, x*y) for y in range(1, x+1)]) for x in range(1, 10)]))
簡單版本
1 first = 1 #被乘數初始值2#
second = 9
3while first <= 9:4#
print(str(first)+"*"+str(first)+"=",first)
5 sec = 1 #
乘數初始值
6while sec <= first: #
9*9時結束 #end="\t" \n = 換行 \t = tab鍵
7print(str(sec),'
*',str(first),'
=',(str(sec * first)),end="
\t") #
用,隔開中間有距離,+則沒有
8 sec += 1
9print() #
另起一行的作用
10 first += 1
python九九乘法表
之前愛人用excel寫了九九乘法表 if and column a1 row a1 row a1 10 column a1 row a1 column a1 row a1 試試用python寫乙個九九乘法表。重構a a乘法表 函式 def jjcfb a for i in range 1,a 1 f...
Python 九九乘法表
以下例項演示了如何實現九九乘法表 coding utf 8 filename test.py author by www.runoob.com 九九乘法表 通過指定end引數的值,可以取消在末尾輸出回車符,實現不換行。for i in range 1 10 for j in range 1 i 1 ...
python 九九乘法表
詳解 為了讓自己理解 for i in range 1,10 print i,end for j in range 1,i 1 print s s s i,j,i j end print 1.for i in range 1,10 這是乙個for 迴圈 語句,range 是乙個函式,for i in...