Cbre一般员工工资多少:pythonif和else语句计算员工工资

关于Cbre一般员工工资多少的问题,在how to add up time and a half中经常遇到, 我在这个任务上遇到了一点麻烦,它是关于计算员工的工资,就像写一个 Python 程序,提示用户每小时的工资和工作小时数,并计算工资金额。任何工作超过 40 小时的时间都是按时间支付的(正常小时工资的 1.5 倍)。使用 if / else 编写一个程序版本我的代码到目前为止是这样的

我在这个任务上遇到了一点麻烦,它是关于计算员工的工资,就像写一个 Python 程序,提示用户每小时的工资和工作小时数,并计算工资金额。任何工作超过 40 小时的时间都是按时间支付的(正常小时工资的 1.5 倍)。使用 if / else 编写一个程序版本我的代码到目前为止是这样的

hours = int(input('how many hours did you work? '))
rate = 1.50
rate = (hours/2)+hours*(rate+1.5)
if hours<40:
 print("you earn",rate)
3

如果您需要从用户输入小时费率,您可以这样做:

hours = int(input('how many hours did you work? '))
rate = int(input('what is your hourly rate? '))

然后,一旦你有了这些变量,你就可以从计算加班开始。

if hours > 40:
  # anything over 40 hours earns the overtime rate
  overtimeRate = 1.5 * rate
  overtime = (hours-40) * overtimeRate
  # the remaining 40 hours will earn the regular rate
  hours = 40
else:
  # if you didn't work over 40 hours, there is no overtime
  overtime = 0

然后计算常规时间:

regular = hours * rate

您的总薪酬为regular + overtime

2
print("you earn", (hours + max(hours - 40, 0) * 0.5) * rate)

或高尔夫版本

print("you earn", (hours*3-min(40,hours))*rate/2)
1

您可以使用:

pay = rate * min(hours, 40)
if hours > 40:
    pay += rate * 1.5 * (hours - 40)

根据工作小时数调整薪酬计算。

您可能应该熟悉this resource

0

一些提示:

您还需要提示用户其小时费率。

它是rate * 1.5,而不是rate + 1.5。该费率仅适用于过去40 小时,因此对于前 40 小时,您应用常规费率:

if hours <= 40:
    total = hours * rate
else:
    total = 40 * rate + (hours - 40) * (1.5 * rate)

本站系公益性非盈利分享网址,本文来自用户投稿,不代表码文网立场,如若转载,请注明出处

(368)
Python输出helloworld代码:错误:helloworld的外壳代码(at& t)的非法指令
上一篇
All in all: all-all和~all在DNS (spf)配置中
下一篇

相关推荐

发表评论

登录 后才能评论

评论列表(72条)