#coding=utf-8 lst = [3,6,2,7] number_lst = [] for i in lst: for j in lst: for k in lst: if i != j and i != k and j != k: # 去重 number_lst.append( '{first}{second}{third}'.format( first=i, second=j, third=k))
print('共有{count}个符合条件的数字'.format( count=len(number_lst))) for item in number_lst: print item
# 第一题 方法一 numbers = [x*x for x inrange(1, 10001)] for num in numbers: print(num) # 第一题 方法二 num = 1 while num < 10001: print(num*num) num += 1 # 第二题 num = 1 squares = [] whileTrue: square = num*num if square > 10268: break num += 1 squares.append(square)
for square in squares: if (square + 168) in squares: print(square - 100)
defget_line(number): line = "" str_foramt = "{left}*{right} = {result}" for i inrange(1, number+1): if i != 1: line += " \t" line += str_foramt.format(left=i, right=number, result=i*number) return line