【问题标题】:how can input hourly rate and gross income in python?如何在 python 中输入小时费率和总收入?
【发布时间】:2020-05-09 07:22:32
【问题描述】:

在课堂上编写一个程序,使用输入来计算总工资,提示用户输入小时数和每小时费率。支付不超过 40 小时的小时费率和超过 40 小时的所有小时费率的 1.5 倍。使用 45 小时和每小时 10.50 的费率来测试程序(工资应该是 498.75)。您应该使用 input 读取字符串并使用 float() 将字符串转换为数字

【问题讨论】:

  • 到目前为止你尝试了什么?你的结果是什么?另见:stackoverflow.com/help/how-to-ask
  • 我们不会做你的功课。向我们展示您迄今为止的尝试!

标签: python python-3.x python-2.7


【解决方案1】:

如问题输入使用中所问:

hrs = input()
rph = input()
hrs = float(hrs)
rph = float(rph)

顺便说一句更短的方式:

hrs = float(input())
rph = float(input())

【讨论】:

  • 它根据 python 3.x
  • 对于 python 2.x 将 input() 替换为 raw_input()
猜你喜欢
  • 1970-01-01
  • 2020-08-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-02-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多