1、有四个数字:1、2、3、4,打印出互不相同且无重复数字的三位数?
例如 打印出数字如下:
1 2 3
1 2 4
def test():
li = [1, 2, 3, 4]
a = 0
for i in li:
for j in li:
for k in li:
if i != j and i != k and j != k:
print(i, j, k)
a += 1
print("共有 {0} 个".format(a))
if __name__ == '__main__':
res = test()
i = int(input("净利润:"))
arr = [1000000,600000,400000,200000,100000,0]
rat = [0.01,0.015,0.03,0.05,0.075,0.1]
r = 0
for idx in range(0,6):
if i>arr[idx]:
tmp = (i-arr[idx]*rat[idx])
r = r+tmp
i = arr[idx]
print(r)
for i in range(1,85):
if 168 % i == 0:
j = 168/i
if i > j and (i+j)%2 ==0 and (i-j)%2 == 0:
m = (i+j)/2
n = (i-j)/2
x = n*n -100
print(x)
year = int(input("year:"))
month = int(input("month:"))
day = int(input("day:"))
#非闰年
months = (0,31,59,90,120,151,181,212,243,273,304,334)
if 0 sum = months[month-1] else: print('data error') sum += day #计算闰年的条件:能被4整除而不能被100整除,能被100整除,也能被100整除 leap = 0 if (year%400 == 0) or ((year%4 == 0) and (year % 100 !=0)): leap = 1 if (leap == 1) and (month>2): sum+=1 print("it is the %dth day"%sum) l = [] for i in range(3): x = int(input("integer:")) l.append(x) l.sort() print(l) def fib(n): if n == 1 or n==2: return (1) return fib(n-1) + fib(n-2) print(fib(10)) #使用列表[:]全选元素 list1 = [1,2,3] list2 = list1[:] print(list2) for i in range(1,10): for j in range(1,i+1): print("%d * %d = %d"%(i,j,i*j),end ='\t') print() #用time包 import time for i in range(1,5): print(i) time.sleep(1) import time for i in range(10): print(time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())) time.sleep(1)