该代码应该可以计算出一周的生产量,但是我无法确定如何使最终结果“无”。 它将每周工作时间乘以每天工作时间。 任何帮助都会很棒。
def WeeklyPay(t,z,x,c,v,b,n):
WeeklyPayOverall = (t*(z,x,c,v,b,n,))
employeeName = input("What is your name : ")
hourlyPayRate = int(input("What is your hourly pay : "))
hoursWorkedMonday = int(input("How many hours did you work on Monday : "))
hoursWorkedTuesday = int(input("How many hours did you work on Tuesday : "))
hoursWorkedWednesday = int(input("How many hours did you work on Wednesday : "))
hoursWorkedThursday = int(input("How many hours did you work on Thursday : "))
hoursWorkedFriday = int(input("How many hours did you work on Friday : "))
hoursWorkedSaturday = int(input("How many hours did you work on Saturday : "))
hoursWorkedSunday = int
(input("How many hours did you work on Sunday : "))
result = (WeeklyPay(hoursWorkedMonday,hoursWorkedTuesday,hoursWorkedWednesday,hoursWorkedThursday,hoursWorkedFriday,hoursWorkedSaturday,hoursWorkedSunday))
print(employeeName,"Your Weekly pay is £", result)
答案 0 :(得分:1)
您没有返回值;您只是将其保存到局部变量,然后(隐式)返回None
。您实际上还需要累计每天的工作时间。你想要
def WeeklyPay(t, z, x, c, v, b, n):
return t * (z + x + c + v + b + n)
最后,您缺少参数;您只有7个(小时费率和6个每天的小时),但是您需要8个(小时费率和7个每天的小时)。
调用函数时,还需要传递hourlyPayRate
作为第一个参数。您目前仅通过每天的工作时间。