【问题标题】:python3 increase in salary over previous yearpython3加薪比上一年
【发布时间】:2013-05-30 04:22:20
【问题描述】:

我不断收到错误消息:TypeError: unsupported operand type(s) for *: 'dict' and 'float' 我已经将其更改为浮点数,但它不起作用。请指教!

job = {'fireman': 42600, 'librarian': 35000, 'clerk': 23000}

salary = float(job * 1.05 ** years_of_service)

return salary

...

这是解决方法,还是有更简单的方法?

谢谢!

【问题讨论】:

    标签: if-statement python-3.x boolean


    【解决方案1】:

    公式为salary * 1.05**years。注意** 是取幂。

    【讨论】:

      【解决方案2】:

      首先,获取包含他们工资的职位地图;为此,请使用字典(Python 中唯一的映射类型):

      job_salary = {'engineer': 73200, 'programmer': 48700, 'retail': 23000}

      添加奖金的公式是salary x 1+percentage increase。现在我让你来解决剩下的问题。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-08-05
        • 2021-01-25
        • 1970-01-01
        • 2022-11-14
        • 1970-01-01
        • 2019-05-30
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多