Python薪资计划

时间:2014-11-10 02:28:03

标签: python-2.7

我有一份工作计划,我正在做功课。我需要向每位员工询问3个问题,直到他们完成为止。我已经完成了以下工作。我完全迷失的部分是计算工资。到目前为止似乎以下是正确的。任何帮助和提示将不胜感激。

def GetInfo():

    lstNames = []
    lstHours = []
    lstRate = []

    blnDone = False
    while blnDone == False:
        strName = raw_input("\nEnter employee full name: ")
        if len(strName) == 0: #did the user press enter?
            print "Invalid entry. Please try again.\n"
            strName = raw_input("Enter a your full name: ")
        else:
            lstNames.append(strName.title())

        strHours = raw_input("Enter employee hours worked (between 1-60): ")
        if int(strHours) < 1 or int(strHours) > 60:
            print "Invalid entry. Please try again.\n"
            strHours = raw_input("Enter your hours worked (between 1-60): ")
        else:
            lstHours.append(int(strHours))

        strRate = raw_input("Enter employee hourly wage (between 6.00-20.00: ")
        if float(strRate) < 6.00 or float(strRate) > 20.00:
            print "Invalid entry. Please try again.\n"
            strRate = raw_input("Enter your hourly wage (between 6.00-20.00: ")
        else:
            lstRate.append(float(strRate))

        strDone = raw_input("Are you done entering employee information? (yes/no): ")
        if strDone.lower() == "yes":
            blnDone = True
        elif strDone.lower()== "no":
            blnDone = False
        elif strDone.lower() != "yes" or strDone != "no":
            print "Invalid entry. Please try again.\n"
            strDone = raw_input("Are you done entering employee information? (yes/no): ")

    return strName, strHours, strRate, lstNames, lstHours, lstRate
主线

1 个答案:

答案 0 :(得分:0)

添加类似这样的新功能:

def payFunc():
    info = getInfo()
    lstHours = info[3]
    lstRate = info[5]
    if lstHours >40:
        pay = (40*lstRate)+((lstHours-40)*(1.5*lstRate))
    elif lstHours =<40:
        pay = (lstRate*lstHours)
    return(pay)

print(payFunc)