• Python编程练习题和答案实例二:关于数轴和长整型数据类型的练习。


    Python练习题问题如下:

    简述:企业发放的奖金根据利润提成。利润(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('Profit='))
    a = profit * 0.1
    b = (profit - 100000) * 0.075
    c = (profit - 200000) * 0.05
    d = (profit - 400000) * 0.03
    e = (profit - 600000) * 0.015
    f = (profit - 1000000) * 0.01
    if profit <= 100000:
        print(a)
    if 100000 < profit <= 200000:
        print(a + b)
    if 200000 < profit <= 400000:
        print(a + b + c)
    if 400000 < profit <= 600000:
        print(a + b + c + d)
    if 600000 < profit <= 1000000:
        print(a + b + c + d + e)
    if 1000000 < profit:
        print(a + b + c + d + e + f)
    #答案算法,也算是明白了,要多练习掌握
    a = [1000000, 600000, 400000, 200000, 100000, 0]
    b = [0.01, 0.015, 0.03, 0.05, 0.075, 0.1]
    profit = int(input('>>>'))
    bonus = 0
    for i in range(6):
        if profit > a[i]:
            bonus += (profit - a[i]) * b[i]
    print(bonus)
  • 相关阅读:
    spring中的异步事件
    spring中的事件 applicationevent 讲的确实不错
    freemark2pdf
    使用Ajax生成的Excel文件并下載
    1.智帮校园App功能概况
    MVC4 Controller器同名问题
    MVC 数据验证
    补丁惹的祸-ContractName Microsoft.VisualStudio.Text.ITextDocumentFactoryService
    .Net MVC4 加.html后缀报404问题
    VS2012常用快捷建(必备)
  • 原文地址:https://www.cnblogs.com/xusuns/p/8276290.html
Copyright © 2020-2023  润新知