在我的Python程序中获取应该计算工资单信息的类型错误

时间:2014-06-22 01:58:31

标签: python function

TypeError: get_info() takes exactly 3 arguments (0 given)

以下是代码:

def get_info(name,hrs_wrkd,payrate):
    print('is this working?');
    name = input('What is the last name of the employee?');
    hrs_wrkd = float(input('How many hours did',name,' work last week?'));
    payrate = float(input('How much does',name,' get paid?'));
    return name,hrs_wrkd,payrate

#This function should be to calculate the employee's regular pay hours
#It accepts arguments from get_info

def calculate_reg_pay(hrs_wrkd,payrate):
    reg_hrs = hrs_wrkd
    reg_pay = reg_hrs * payrate
    OT_hrs = 0
    OT_pay = 0
    return reg_hrs,reg_pay,OT_hrs,OT_pay

#This function should calculate the Overtime pay for the employee
#It accepts arguments from the get_info function as well

def calculate_OT_pay(hrs_wrkd,payrate):
    reg_hrs = hrs_wkrd - 40
    reg_pay = reg_hrs * payrate
    OT_hrs = hrs_wrkd - reg_hrs
    OT_pay = OT_hrs * (payrate * 1.5)
    return reg_hrs,reg_pay,OT_hrs,OT_pay

#This function decides which calculation to use, either OT or regular pay
#It also accepts srguments from get_info

def calc_employee(hrs_wrkd,payrate):
    if hrs_wrkd <= 40:
        calculate_reg_pay(hrs_wrkd,payrate)
    else:
        calculate_OT_pay(hrs -wrkd,payrate)
    return reg_hrs,OT_hrs,reg_ay,reg_hrs

#This function should print the single employee information after it was calculated
#It gets its arguments from the calc_employee function

def print_employee(reg_pay,OT_pay,name):
    print(name,'earned $',format(reg_pay,'.2f'),' worth of regular pay and ',format(OT_pay,'.2f'),' in overtime this week.')

#This function is supposed to calculate the running total of the hours and pay for overtime and regular pay for the company
# It accepts its arguments from the calc_employee function also

def running_total(reg_hrs,reg_pay,OT_hrs,OT_pay,total_reg_hrs,total_reg_pay,total_OT_hrs,total_OT_pay):
    total_reg_hrs = total_reg_hrs + reg_hrs
    total_reg_pay = total_reg_pay + reg_pay
    total_OT_hrs = total_OT_hrs + OT_hrs
    total_OT_pay = total_OT_pay + OT_pay

#This function is supposed to print out the running total for the company, but I realized that it isnt in the proper position when called

def print_totals(total_reg_hrs,total_reg_pay,total_OT_hrs,total_OT_pay):
    print('The total regular hours worked was',total_reg_hours)
    print('The total regular pay was $',format(total_reg_pay,'.2f'))
    print('The total overtime hours worked was',total_OT_hours)
    print('The total overtime pay was $',format(total_OT_pay,'.2f'))

# So here I am defining the main loop that will activate everytime the user selects Yes
#It calls most of the other functions

def main_loop():
    get_info
    calc_employee
    print_employee
    running_total

#Here I am defining the main program where I put the loop control



def main():
    name,hrs_wrkd,payrate = get_info()
    reg_hrs,reg_pay,OT_hrs,OT_pay = calc_employee(hrs_wrkd,payrate)
    total_reg_hrs,total_reg_pay,total_OT_hrs,total_OT_pay = running_total
    loop_control = input("Would you like to enter an employee's name, payrate and hours? y to do so")
    if loop_control == "y":
        main_loop
    else:
        print_totals(total_reg_hrs,total_reg_pay,total_OT_hrs,total_OT_pay)
#Here we call the main function

main()

1 个答案:

答案 0 :(得分:0)

函数get_info()的参数列表应为空,如下所示:

def get_info():