zoukankan      html  css  js  c++  java
  • 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)
  • 相关阅读:
    windows系统调用 互斥体mutex
    windows系统调用 利用事件对象实现进程通信
    windows系统调用 调度优先级
    <十四>JDBC_c3p0数据库连接池
    <十三>JDBC_dbcp数据库连接池
    <十二>JDBC_批量处理
    <十一>JDBC_事务的处理+隔离
    <十>JDBC_处理Blob类型数据
    <八>JDBC_重构DAO查询方法
    <七>JDBC_使用beanutils工具类操作javaBean
  • 原文地址:https://www.cnblogs.com/xusuns/p/8276290.html
Copyright © 2011-2022 走看看