Learn the Python loop statement, four ways to achieve the 99 multiplication table.
Def jiujiuwhile (a): "Use while for Loop" "I=1 while I<=a:j=1 while J<=i:print "%d X%d =%d\t"% (j,i,i*j), j+=1 i+=1 Print
Def jiujiufor (a): "' Use for For loop ' ' for I in range (1, a+1): for J in range (1, i+1): print" %d x%d =%d\t "% (j,i,j*i), print
Def thisline (a): print "1 x%d =%d"% (a,a), for I in Range (2,a+1): print "\t%d X%d =%d"% (i,a,i*a), Print
def Jiujiudigui (m): if M>1:jiujiudigui (m-1) thisline (m) elif M==1:thisline (1)
Def jiujiulist (a): "How can I use the map () function to calculate this two-dimensional small 99 array at once?" How can you display it in a more canonical format like the previous function? ' For I in Range (1,a+1): Print map (lambda x: "%d x%d =%d"% (x,i,x*i), Range (1,i+1))
Jiujiufor (9) jiujiuwhile (9) Jiujiudigui (9) jiujiulist (9)
This article is from "It changes us" blog, please make sure to keep this source http://charlywoo.blog.51cto.com/4013957/1542979