bozhen 发表于 2017-8-11 19:51:09

try:
    money = int(input('请输入当月利润:'))
except (ValueError,KeyError,EOFError):
    print('输入有误,请重新输入')

if      money <= 100000:
            bonus = money * 0.1
elif    100000 < money < 200000:
            bonus = (100000 * 0.1) + (money - 100000)*0.75
elif    200000 <= money < 400000:
            bonus = (200000 * 0.1) + (money - 200000) * 0.05
elif    400000 <= money < 600000:
            bonus = (400000 * 0.1) + (money - 400000) * 0.03
elif    600000 <= money < 1000000:
            bonus = (600000 * 0.1) + (money - 600000) * 0.15
elif    100 <= money:
            bonus = (1000000 * 0.1) + (money - 1000000) * 0.01

print('奖金是%d' % bonus)

小山90 发表于 2017-8-17 18:30:29

print("-------通过月利润计算应发奖金数量-------")

bonus = 0   #最后输出的奖金数量
temp = input("请输入月利润,单位(万元):")
monthly_profit = int(temp)   #月利润

profit =
rate =

for i in range (0,6):
    if monthly_profit > profit:
      bonus = bonus + (monthly_profit - profit)*(rate)
      monthly_profit = profit
      

print("应发奖金为:")
print(bonus)

木一 发表于 2017-8-19 21:51:33

w = int(input('请输入利润:'))
if w <= 100000:
    t = w * 0.1
elif w < 200000:
    t = 10000 + (w - 100000) * 0.075
elif w < 400000:
    t = 17500 + (w - 200000) * 0.05
elif w < 600000:
    t = 27500 + (w - 400000) * 0.03
elif w < 1000000:
    t = 33500 + (w - 600000) * 0.015
else:
    t = 39500 + (w - 1000000) * 0.01
print('总奖金为:' + str(t))

写得很丑{:10_243:}

badaoqingchen 发表于 2017-8-28 14:05:53

money = int(input("输入利润:"))
rat =
level =
s = 0
i = 0
for each in level:
    if money-each>0:
      s += (money-each)*rat
      money = each
    i += 1
#s += money*rat
print s

badaoqingchen 发表于 2017-8-28 15:03:52

money = int(input("输入利润:"))
rat =
level =
s = 0
for i in range(6):
    if money-level>0:
      s += (money-level)*rat
      money = level
print s

Jocks 发表于 2017-9-6 09:42:12

profit = int(input('请输入月利润:'))
if profit <= 10:
    bonus = profit * 0.1
elif 10 < profit <= 20:
    bonus = 1 + (profit - 10) * 0.75
elif 20 < profit <= 40:
    bonus = 1.75 + (profit -20) * 0.05
elif 40 < profit <= 60:
    bonus = 2.75 + (profit - 40) * 0.03
elif 60 < profit <= 100:
    bonus = 3.35 + (x - 60) * 0.015
elif profit > 100:
    bonus = 3.95 + (profit - 100) * 0.01
print('奖金为%.3f万元' % bonus)

gausser 发表于 2017-9-7 23:10:23

profit = int(raw_input("Enter your profit: "))

if profit <= 100000:
    bonus = profit * 0.1
elif profit < 200000:
    bonus = (profit - 100000) * 0.075 + 100000
elif profit < 400000:
    bonus = (profit - 200000) * 0.05 + 100000 * (0.1 + 0.075)
elif profit < 600000:
    bonus = (profit - 400000) * 0.03 + 200000 * 0.05 + 100000 * (0.1 + 0.075)
elif profit < 1000000:
    bonus = (profit - 600000) * 0.015 + 200000 * (0.05 + 0.03) + 100000 * (0.1 + 0.075)
else:
    bonus = (profit - 1000000) * 0.01 + 400000 * 0.015 + 200000 * (0.05 + 0.03) + 100000 * (0.1 + 0.075)
   
print "Your bonus is: ", bonus   

BngThea 发表于 2017-9-11 10:25:54

def dividend(profit):
    profit /= 10000
    if profit > 100:
      result = 3.95 + 0.01 * (profit - 100)
    elif profit > 60:
      result = 3.35 + 0.015 * (profit - 60)
    elif profit > 40:
      result = 2.75 + 0.03 * (profit - 40)
    elif profit > 20:
      result = 1.75 + 0.05 * (profit - 20)
    elif profit > 10:
      result = 1 + 0.075 * (profit - 10)
    elif profit > 0:
      result = 0.1 * profit
    else:
      print("profit can't be negative")
      return

    result = int(10000 * result)
    profit = int(10000 * profit)
    print('When profit is ' + str(profit) + ', you can get ' + str(result))

while True:
    profit = int(input('Please enter a profit(0 to quit):'))
    if not profit:
      print('Byebye')
      break
    dividend(profit)

张大象 发表于 2017-9-13 15:04:16

arr =
rat =
n = int(input('输入你的净利润:'))
tmp = 0
for i in range(6):
        if n > arr:
                tmp += (n-arr)*rat
                n = arr
print(tmp)

驻火蚁 发表于 2017-9-23 21:37:38

q=0
for i in range(1,5):
    for j in range(1,5):
      for k in range(1,5):
            if i!=j and i!=k and j!=k:
                q+=1
                print(i,j,k,q)

aixuexi82 发表于 2017-9-25 15:17:55

def bouns(i):
    if 0 <= i <=100000:
      return i * 0.1
    elif 100000< i < 200000:
      return 10000 + (i - 100000) * 0.075
    elif 200000 <= i < 400000:
      return 10000 * 0.175 + (i - 200000) * 0.05
    elif 400000 <= i < 600000:
      return 10000 * 0.275 + (i - 400000) * 0.03
    elif 600000 <= i < 1000000:
      return 10000 * 0.335 + (i - 600000) * 0.015
    elif i >= 1000000:
      return 10000 * 0.395 + (i - 1000000) * 0.01

i = float(input('请输入当月利润,单位"元":'))
print('应获得奖金%.2f' % bouns(i))

口可口可 发表于 2017-10-8 22:37:33

本帖最后由 口可口可 于 2017-10-8 22:39 编辑

i = input("请输入本月的利润(单位为元,支持小数):")
while 1:
    try:
      i = float(i)
      break
    except:
      i = input("输入有误,请重新输入:")

arr =
rat =
bouns = 0
for idx in range(0,6):
    if i > arr:
      bouns += (i-arr) * rat
      i = arr
print("应发放奖金:%.2f元"%bouns)

楼主的答案更切题一些,所以借用了一下,增加了输入判断

a778450868 发表于 2017-10-25 21:24:03

开始还很不理解敲了一遍立马顺畅
money = int(input("请输入奖金金额"))
arr =
rate =
sum = 0
for i in range(0,6):
    if money > arr:
      sum += (money - arr) * rate
      i = arr;
      print(sum);
print(sum)

Python玲玲 发表于 2017-11-7 12:42:29

print('当月利润:',end=' ')
i = int(input())
if i <= 10:
    bonus = i * 0.1
    print(bonus)
else:
    if i <= 20:
      bonus = 10*0.1+(i-10)*0.075
      print(bonus)
    else:
      if i <= 40:
            bonus = 10*0.1+10*0.075+(i-20)*0.05
            print(bonus)    #感觉自己代码写的又累赘难看了

nononoyes 发表于 2017-11-28 16:11:43


a = int(input('请输入当月的利润: '))
if a<100000:
    print("应发奖金为: %.2f 元"%(a*(0.1)))

if a>=100000 and a<200000:
    print("应发奖金为: %.2f 元"%(100000*0.1+(a-100000)*0.075))
if a>=200000 and a<400000:
    print("应发奖金为: %.2f 元"%(17500.00+(a-200000)*0.05))
if a>=400000 and a<600000:
    print("应发奖金为: %.2f 元"%(27500.00+(a-400000)*0.03))
if a>=600000 and a<1000000:
    print("应发奖金为: %.2f 元"%(33500.00 +(a-600000)*0.015))
if a>=1000000:
    print("应发奖金为: %.2f 元"%(39500.00 +(a-1000000)*0.01))

shigure_takimi 发表于 2017-12-1 16:24:27

def getBonus(profit):
    if profit <= 100000:
      return profit*0.1
    elif profit <= 200000:
      return (profit-100000)*0.075 + 100000*0.1
    elif profit <= 400000:
      return (profit-200000)*0.05 + 100000*0.1 + 100000*0.75
    elif profit <= 600000:
      return (profit-400000)*0.03 + 100000*0.1 + 100000*0.75 + 200000*0.05
    elif profit <= 1000000:
      return (profit-600000)*0.015 + 100000*0.1 + 100000*0.75 + 200000*0.05 + 200000*0.03
    else:
      return (profit-1000000)*0.01 + 100000*0.1 + 100000*0.75 + 200000*0.05 + 200000*0.03 + 400000*0.015

print(getBonus(1250000))

#109500.0

TheonHuang 发表于 2017-12-2 19:31:48

profit = input('请输入当月利润:')
i = int(profit)
if i <= 100000 :
    prize = int(i * 0.1)
elif 100000 <= i <= 200000:
    prize = int(10000 + (i - 100000) * 0.075)
elif 200000 <= i <= 400000:
    prize = int(17500 + (i - 200000) * 0.05)
elif 400000 <= i <= 600000:
    prize = int(27500 + (i - 400000) * 0.03)
elif 600000 <= i <= 1000000:
    prize = int(33500 + (i - 600000) * 0.015)
else :
    prize = int(39500 + (i - 1000000) * 0.01)
print('您的奖金为:' + str(prize))

没看答案之前写的,感觉还得好好学习,列表完全不会,检验机制不知道加,有点蠢orz

moyuqqxing 发表于 2017-12-6 18:36:17

貌似大家的程序中,用数学思维求解的更好理解一点,对于我这种新手更容易明白。还得加油追赶各位了。

小熊猫的python 发表于 2018-1-3 15:59:45

渡漫 发表于 2017-5-21 20:43
小弟不才

个人觉得你的答案是这里面最易读的,一目了然。支持!

xiaoying123 发表于 2018-1-4 10:29:24

def calc(I):
      if I<=100000:
            return I*0.1
      elif 100000<I<=200000:
            return 10000+(I-100000)*0.075
      elif 200000<I<=400000:
            return 17500+(I-200000)*0.05
      elif 400000<I<=600000:
            return 27500+(I-400000)*0.03
      elif 600000<I<=1000000:
            return 33500+(I-600000)*0.015
       elif I>1000000:
            return 39500+(I-1000000)*0.01

while True:
   data=int(input("请输入当月利润: "))
   money=calc(data)
   print("本月应发放奖金总数:",money)
页: 1 [2] 3 4 5 6 7
查看完整版本: Python:每日一题 2