【发布时间】:2019-02-22 11:26:29
【问题描述】:
如果有人可以给我一些提示,为我指明正确的方向,这样我就可以自己解决它,那就太好了。 我正在尝试根据员工人数计算总收入和平均收入。我是否必须制作另一个列表或迭代当前列表(list1)才能解决。
def get_input():
Name = input("Enter a name: ")
Hours = float(input("Enter hours worked: "))
Rate = float(input("Enter hourly rate: "))
return Name, Hours, Rate
def calc_pay(Hours, Rate):
if Hours > 40:
overtime = (40 * Rate) + (Hours - 40) * (Rate * 1.5)
print(list1[0], "should be paid", overtime)
else:
no_overtime = (Hours * Rate)
print(list1[0], "should be paid", no_overtime)
return Hours, Rate
x = int(input("Enter the number of employees: "))
for i in range(x):
list1 = list(get_input())
calc_pay(list1[1], list1[2])
i += 1
【问题讨论】:
-
你几乎得到它 OP。您需要做的就是调用
get_input()函数并存储返回值。然后,您需要将这些值传递给calc_pay()函数
标签: python-3.x