124646646 发表于 2018-3-24 00:07:45

jiexian =
ticheng =
temp = float(input("输入当月利润:"))
money = 0
suyin = len(ticheng)
for i in range(suyin):
    if temp>jiexian[-(i+1)]:
      money += (temp-jiexian[-(i+1)])*ticheng[-(i+1)]
      temp = jiexian[-(i+1)]
print(money)

jhgyz126 发表于 2018-3-29 16:59:56

参考大家的写法,也贴一下

def profitInput():
    try:
      profit = float(input('请输入利润(单位为元,精确到小数点后两位,输入0退出):'))
      return profit
    except:
      print('输入有误,请重新输入')
      return profitInput()

def pushMoneyFunc():
    myProfit = profitInput()
    if myProfit <= 100000:
      return myProfit * 0.1
    elif myProfit <= 200000:
      return 100000 * 0.1 +(myProfit-100000) * 0.075
    elif myProfit <= 400000:
      return 100000 * 0.1 + 100000 * 0.075 + (myProfit-200000) * 0.05
    elif myProfit <= 600000:
      return 100000 * 0.1 + 100000 * 0.075 + 200000 * 0.05 + (myProfit-400000) * 0.03
    elif myProfit <= 1000000:
      return 100000 * 0.1 + 100000 * 0.075 + 200000 * 0.05 + 200000 * 0.03 + (myProfit-60000) * 0.015
    else:
      return 100000 * 0.1 + 100000 * 0.075 + 200000 * 0.05 + 200000 * 0.03 + 400000 * 0.015 + (myProfit - 1000000) * 0.01

while True:
    pushMoney = pushMoneyFunc()
    if pushMoney == 0:
      break
    else:
      print(pushMoney)

today0427 发表于 2018-3-30 19:09:47

我的
def profits(money):
    list=[(100,0.01),(60,0.015),(40,0.03),(20,0.05),(10,0.075),(0,0.1)]
    n=0
    for x,y in list:
      if money>x:
            n=n+(money-x)*y
            money=x
    return n

我师傅改造成递归

def jjj(n):
    list=[(100,0.01),(60,0.015),(40,0.03),(20,0.05),(10,0.075),(0,0.1)]
    if n==0:
      return 0
    for x,y in list:
      if n>x:
            s=(n-x)*y+jjj(x)
            break
    return s

tsembrace 发表于 2018-4-6 23:28:37

'''
企业发放的奖金根据利润提成。
利润(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,求应发放奖金总数?
'''
def bonus0_10(i):
    return i*0.1
def bonus10_20(i):
    return bonus0_10(100000)+(i-100000)*0.075
def bonus20_40(i):
    return bonus10_20(200000)+(i-200000)*0.05
def bonus40_60(i):
    return bonus20_40(400000)+(i-400000)*0.03
def bonus60_100(i):
    return bonus40_60(600000)+(i-600000)*0.015
def bonus100_(i):
    return bonus60_100(1000000)+(i-1000000)*0.01

def count_bonus(i):
    if i<=100000:
      return bonus0_10
    elif i<=200000:
      return bonus10_20
    elif i<=400000:
      return bonus20_40
    elif i<=600000:
      return bonus40_60
    elif i<=1000000:
      return bonus60_100
    else:
      return bonus100_

if __name__=='__main__':
    i=int(input('请输入当月的利润额:\n'))
    print("当月奖金为:%0.2f元。"% count_bonus(i)(i))
      

ZSS0519 发表于 2018-4-15 13:56:56

def my_profit(i):
    if i>0 and i<=10:
      return(i+i*0.1)
      if i>10 and i<=20:
            return((i-10)*0.075+10*0.1)
            if i>20 and i<=40:
                return((i-20)*0.05+10*0.1+10*0.075)
                if i>40 and i<=60:
                   return((i-40)*0.03+10*0.1+10*0.075+20*0.05)
                   if i>60 and i<=100:
                     return((i-60)*0.015+20*0.03+10*0.1+10*0.075+20*0.05)
    else:
      print((i-100)*0.01+40*0.015+20*0.03+10*0.1+10*0.075+20*0.05)

天天学习$ 发表于 2018-4-18 18:33:30

profit = int(input('请输入企业利润(单位:万元):'))
if profit <= 10:
    award = profit * 0.1
elif profit <= 20:
    award = (10 * 0.1) + (profit - 10) * 0.075
elif profit <= 40:
    award = (10 * (0.1 + 0.075)) + (profit - 20) * 0.05
elif profit <= 60:
    award = (10 * 0.1) + (10 * 0.075) + (10 * 0.05) + (profit - 40) * 0.03
elif profit <= 100:
    award = (10 * 0.1) + (10 * 0.075) + (10 * 0.05) + (10 * 0.03) + (profit - 60) *0.015
else:
    award = (10 * 0.1) + (10 * 0.075) + (10 * 0.05) + (10 * 0.03) + (10 *0.015) + (profit - 100) * 0.01
print('奖金是:',award)

树树 发表于 2018-4-19 11:52:41

#b-bonus,为奖金;p-profit,为利润
b = 0
p = input("请输入本月利润额:(单位为万元!)")
p = float(p)

if 0 < p <= 10:
    b = p*0.1
if 10 < p <= 20:
    b = 10*0.1 + (p-10)*0.075
if 20 < p <= 40:
    b = 10 * 0.1 + 10 *0.075 + (p-20)* 0.05
if 40 < p <= 60:
    b = 10 *0.1 + 10 * 0.075 + 20 * 0.05 + (p - 40) *0.03
if 60 < p <= 100:
    b = 10 * 0.1 + 10 *0.075 + 20*0.05 + 20 *0.03 + (p - 60) * 0.015
if p > 100:
    b = 10 * 0.1 + 10 * 0.075 + 20*0.05 + 20 *0.03 + 40 *0.015 + (p-100)*0.01

print("当月应得奖金为%s 万元." %(b))

BISHIQIUQIUI 发表于 2018-5-8 17:23:54

i = int(input("净利润:"))
arr =
rat =
r = 0
k = 0
for n in range (0,6):
    if i > arr:
      r+=(i-arr)*rat
      k+=1
      print((arr),"档: ",(i-arr)*rat)
      m = arr
print ("奖金总计:",r)

浮光y掠影 发表于 2018-5-12 20:13:22

I=int(input('利润为:'))
if I<=0:
    print('啊哦,扣你钱~~')
elif I<=100000:
    print( I*0.1)
elif 100000<I<=200000:
    print( (I-100000)*0.075+10000)
elif 200000<I<=400000:
    print( 17500+(I-200000)*0.05)
elif 400000<I<=600000:
    print( 27500*0.05+(I-400000)*0.03)
elif 600000<I<=1000000:
    print( 33500+(I-600000)*0.015)
else:
    print( 39500+(I-1000000)*0.01)

张大哈 发表于 2018-6-3 10:54:17

c=input("请输入当月利润(元):")
i=int(c)
if i<=100000:
         salary=i*0.1
elif100000<i<=200000:
         salary=10000+(i-100000)*0.075
elif 200000<i<=400000:
         salary=10000+7500+(i-20000)*0.05
elif 400000<i<=600000:
         salary=10000+7500+10000+(i-40000)*0.03
elif 600000<i<=1000000:
         salary=10000+7500+10000+6000+(i-60000)*0.015
else:
         salary=10000+7500+10000+6000+6000+(i-1000000)*0.01
print(salary)

Loey 发表于 2018-7-11 21:22:37

I = int(input('请输入本月利润:'))
if I <= 100000:
    bonuses = I * 0.1
elif I <= 200000:
    bonuses = (I - 100000) * 0.075 + 100000 * 0.1
elif I <= 400000:
    bonuses = (I - 200000) * 0.05 + (200000 - 100000) * 0.075 + 100000 * 0.1
elif I <= 600000:
    bonuses = (I - 400000) * 0.03 + (400000 - 200000) * 0.05 + (200000 - 100000) * 0.075 + 100000 * 0.1
elif I <= 1000000:
    bonuses = (I - 600000) * 0.15 + (600000 - 400000) * 0.03 + (400000 - 200000) * 0.05 + (200000 - 100000) * 0.075 + 100000 * 0.1
else:
    bonuses = (I - 1000000) * 0.15 + (1000000 - 600000) * 0.15 + (600000 - 400000) * 0.03 + (400000 - 200000) * 0.05 + (200000 - 100000) * 0.075 + 100000 * 0.1

print('本月奖金为:',bonuses)   

astray123 发表于 2018-7-12 14:57:50

while True:
    j = input('输入利润: ')
    if((j.isdigit() != 1)&(j != 'Q') & (j != 'q') ):
      print('非法输入,请重新输入数字-->',end = '')
      continue
    if((j == 'Q') | (j == 'q')):
      print('退出')
      break
    else:
      i = int(j)
      if i <= 100000:
            bonus = i*0.1
      elif 100000<i<=200000:
            bonus = 100000*0.1+(i-100000)*0.075
      elif 200000<i<=400000:
            bonus = 100000*0.1+100000*0.075+(i-200000)*0.05
      elif 400000<i<=600000:
            bonus = 100000*0.1+100000*0.075+200000*0.05+(i-400000)*0.03
      elif 600000<i<=1000000:
            bonus = 100000*0.1+100000*0.075+200000*0.05+200000*0.03+(i-600000)*0.015
      elif i>1000000:
            bonus = 100000*0.1+100000*0.075+200000*0.05+200000*0.03+400000*0.015+(i-1000000)*0.01
      else:
            bonus = 0
            
      print(bonus)

892427369 发表于 2018-7-17 14:33:25

I = float(input('Input the interest:'))
if I > 1000000:
    bonus = 39500.0 + (I - 1000000) * 0.01
elif 600000 < I <= 1000000:
    bonus = 33500.0 + (I - 1000000) * 0.01
elif 400000 < I <= 600000:
    bonus = 27500.0 + (I - 400000) * 0.03
elif 200000 < I <= 400000:
    bonus = 17500.0 + (I - 200000) * 0.05
elif 100000 < I <= 200000:
    bonus = 10000.0 + (I - 100000) * 0.075
elif 100000 >= I > 0:
    bonus = I * 0.1
else:
    print('没钱!')
    bonus = 0
if bonus > 0:
    print(bonus)

小强工作室 发表于 2018-7-26 14:37:03

def profit(x):
    d={0:0.1,10:0.075,20:0.05,40:0.03,60:0.015,100:0.01}#建立区间字典
    sum=0
    for i in d.keys():#遍历字典的键
      if i<x:#得到小于x的键
            sum+=(x-i)*d#累加(键*键值)
    return sum
if __name__=="__main__":
    print(profit(101))

eshama 发表于 2018-7-31 17:08:51

学习学习下

DavidCowboy 发表于 2018-7-31 17:14:45

amount = int(input('請輸入利潤額:'))

if amount <= 100000:
             bonus = amount * 0.1
elif 100000 < amount <= 200000:
             bonus = 100000 * 0.1 + (amount - 100000) * 0.075
elif 200000 < amount <= 400000:
             bonus = 100000 * 0.1 + 100000 * 0.075 + (amount - 200000) * 0.05
elif 400000 < amount <= 600000:
             bonus = 100000 * 0.1 + 100000 * 0.075 + 200000 * 0.05 + (amount - 400000) * 0.03
elif 600000 < amount <= 1000000:
             bonus = 100000 * 0.1 + 100000 * 0.075 + 200000 * 0.05 + 200000 * 0.03 + (amount - 600000) * 0.015
elif amount > 1000000:
             bonus = 100000 * 0.1 + 100000 * 0.075 + 200000 * 0.05 + 200000 * 0.03 + 400000 * 0.15 + (amount - 1000000) * 0.01
print('年度利潤額是: ' , amount , '元整' , ',換算核發獎金為: ' , bonus , '元整')

uilUVUBWP 发表于 2018-8-5 09:17:32

I = int(input('请输入本月利润(万元):'))
if I <= 10:
    print('应发总奖金%s万元' %(I + I * 0.1))
elif10 < I <= 20 :
    ifI <= 10:
      print('应发总奖金%s万元' %(I + I * 0.1))
    else:
      print('应发总奖金%s万元' %(I + I * 0.075))
elif 20 < I <= 40:
   print('应发总奖金%s万元' %(I + I * 0.05))
elif 40 < I <= 60:
    print('应发总奖金%s万元' %(I + I * 0.03))
elif 60 < I <= 100:
    if 60 < I:
      print('应发总奖金%s万元' %(I + I * 0.015))
elif I > 100:
      print('应发总奖金%s万元' %(I + (I - 100) * 0.01))
新手不知道对不对

pakhay 发表于 2018-8-6 11:36:25

I = int(input("please input the profit:"))

if I <= 10:
        bonus = I * 0.1
elif I <= 20:
        bonus = 1 + ( I - 10 ) * 0.075
elif I <= 40:
        bonus = 1 + 0.75 + ( I - 20 ) * 0.05
elif I <= 60:
        bonus = 1 + 0.75 + 1 + ( I - 40 ) * 0.03
elif I <= 100:
        bonus = 1 + 0.75 + 1 + 0.6 + ( I - 60 ) * 0.015
else:
        bonus = 1 + 0.75 + 1 + 0.6 + 0.6 + ( I - 100 ) * 0.01
       
print("应当发放奖金总数:%0.2f" % bonus + "万元")

songmenghua 发表于 2018-8-11 14:04:11

I = float(raw_input ('当月利润为;'))
result = 0
if I > 1000000:
    result = (I-1000000)*0.01+100000*0.1+200000*0.05+200000*0.03+400000*0.015+100000*0.075
elif I>600000 and I <=1000000:
    result = (I-600000)*0.015+100000*0.1+200000*0.05+200000*0.03+100000*0.075
elif I>400000 and I <=600000:
    result = (I-400000)*0.03+100000*0.1+200000*0.05+100000*0.075
elif I>200000 and I<=400000:
    result = (I-200000)*0.05+100000*0.1+100000*0.075
elif I>100000 and I<=200000:
    result = (I-100000)*0.075+100000*0.1
else:
    result = I*0.1
print '奖金为:', result

一步半个脚印 发表于 2018-8-21 17:33:35

x= int(input('please input your profit number (the unit is ten thousand):' ))
y=0
if x <= 10 :
        y = x * 0.1
elif 10 <x <= 20 :
        y= (x-10)*0.075+10*0.1
elif 20<x<=40:
        y=(x-20)*0.05+(x-10)*0.075+10*0.1
elif 40<x<=60:
        y=(x-40)*0.03+(x-20)*0.05+(x-10)*0.075+10*0.1
elif 60<x<=100:
        y=(x-60)*0.015+(x-40)*0.03+(x-20)*0.05+(x-10)*0.075+10*0.1
elif 100 < x :
        y=(x-100)*0.01+(x-60)*0.015+(x-40)*0.03+(x-20)*0.05+(x-10)*0.075+10*0.1

print(y)


费脑。。。。
页: 1 2 3 [4] 5 6 7
查看完整版本: Python:每日一题 2