九九乘法表的两种写法

九九乘法表的写法:

 1 #!/usr/bin/env python
 2 #coding:utf8
 3 y = 1
 4 f = lambda x,y:str(x)+' x '+str(y)     #使用lambda写法
 5 while(y<10):
 6     for x in range(1,y+1):
 7         #print x ,'x',y,"	",        #常规写法
 8         print f(x,y),"	",           #调用lambda
 9     print "
"
10     y+=1

1 x 1

1 x 2 2 x 2

1 x 3 2 x 3 3 x 3

1 x 4 2 x 4 3 x 4 4 x 4

1 x 5 2 x 5 3 x 5 4 x 5 5 x 5

1 x 6 2 x 6 3 x 6 4 x 6 5 x 6 6 x 6

1 x 7 2 x 7 3 x 7 4 x 7 5 x 7 6 x 7 7 x 7

1 x 8 2 x 8 3 x 8 4 x 8 5 x 8 6 x 8 7 x 8 8 x 8

1 x 9 2 x 9 3 x 9 4 x 9 5 x 9 6 x 9 7 x 9 8 x 9 9 x 9

原文地址:https://www.cnblogs.com/if-then/p/7106904.html