标签:
for i in range(1,5): for j in range(1,5): print(i,j) print("-"*10) ‘‘‘ 1 1 1 2 1 3 1 4 ---------- 2 1 2 2 2 3 2 4 ---------- 3 1 3 2 3 3 3 4 ---------- 4 1 4 2 4 3 4 4 ---------- ‘‘‘
for m in range(1,5): for n in range(1,m+1): print(n,m) print("********") ‘‘‘ 1 1 ******** 1 2 2 2 ******** 1 3 2 3 3 3 ******** 1 4 2 4 3 4 4 4 ******** ‘‘‘
for m in range(1,5): j=6 for n in range(1,j-m): print(m,n) j=j-1 print("*****") ‘‘‘ 1 1 1 2 1 3 1 4 ***** 2 1 2 2 2 3 ***** 3 1 3 2 ***** 4 1 ***** ‘‘‘
def gen(line_cnt): for row in range(1,line_cnt+1): for col in range(row,line_cnt): print("%d%d\t"%(row,col)) print("") if __name__ == ‘__main__‘: gen(5)
def gen(line_cnt): for i in range(1,line_cnt+1): for j in range(i,line_cnt): m=i*j print("%s*%s=%s\t"%(i,j,m)) print("") if __name__ == ‘__main__‘: gen(10)
标签:
原文地址:http://www.cnblogs.com/yunduan2016/p/5496729.html