defgetCombine(lst):for i in lst:
for j in lst:
for k in lst:
if (i != k) and (i != j) and (j != k):
print i, j, k
2. 一个1000以内的整数,它加上100和加上268后都是一个完全平方数,请问该数是多少?
defcompleteNum():import math
for i in range(1000):
x = int(math.sqrt(i + 100))
y = int(math.sqrt(i + 268))
if (x * x == i + 100) and (y * y == i + 268):
return i
3. 给定一个日期字符串(eg:2013-12-31),判断输入日期是当年中的第几天?
defgetDayno(dateStr):
year,month,day = [int(x) for x in dateStr.split('-')]
months = (0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334)
if0 < month <= 12:
sum = months[month - 1]
else:
raise'month out of range'
sum += day
leap = Falseif (year % 400 == 0) or ((year % 4 == 0) and (year % 100 != 0)):
leap = Trueif leap and month > 2:
sum += 1return sum