标签:bsp pytho 试题 python print gen end har oop
打印九九乘法表
思路:利用字符串的连接,梯形输出结果
>>> def st(num): ... l = [] ... for x in xrange(1, num + 1): ... str1 = ‘‘ ... for y in xrange(1, x + 1): ... str1 = str1 + ‘%d * %d = %s ‘ % (y, x, str(y*x)) ... l.append(str1) ... for i in l: ... print i ... >>> >>> >>> st(3) 1 * 1 = 1 1 * 2 = 2 2 * 2 = 4 1 * 3 = 3 2 * 3 = 6 3 * 3 = 9
generated by haroopad
标签:bsp pytho 试题 python print gen end har oop
原文地址:http://www.cnblogs.com/xiaozi-autotestman/p/6091408.html