001 数字组合
有四个数字:1、2、3、4,能组成多少个互不相同且无重复数字的三位数?各是多少?
count = 0for i in range(1, 5):for j in range(1, 5):for k in range(1, 5):if (i != j) and (j != k) and (k != i):print('{0}{1}{2}'.format(i, j, k))count += 1print(count)
import itertoolsa = [1, 2, 3, 4]count = 0for i in itertools.permutations(a, 3):print('{0}{1}{2}'.format(i[0], i[1], i[2]))count += 1print(count)
002 个税计算
企业发放的奖金根据利润提成。利润(I)低于或等于10万元时,奖金可提10%;利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可提成7.5%;20万到40万之间时,高于20万元的部分,可提成5%;40万到60万之间时高于40万元的部分,可提成3%;60万到100万之间时,高于60万元的部分,可提成1.5%,高于100万元时,超过100万元的部分按1%提成,从键盘输入当月利润I,求应发放奖金总数?
profit = int(input()) # 输入利润bonus = 0 # 记录奖金thresholds = [100000, 100000, 200000, 200000, 400000] # 奖金分段rates = [0.1, 0.075, 0.05, 0.03, 0.015, 0.01] # 分段提成for i in range(len(thresholds)):if profit <= thresholds[i]:bonus += profit * rates[i]breakelse:bonus += thresholds[i] * rates[i]profit -= thresholds[i]else: # 奖金大于 100w 部分的提成bonus += profit * rates[i]print(bonus)
