计算员工激励的程序

时间:2019-10-01 04:55:43

标签: python python-3.x

嗨,我是python的新手,我正在尝试创建一个程序,该程序使我可以根据员工的销售代码来计算给定员工的激励。每个员工都有一个具体的目标要实现。目标可能实现,也可能没有实现。我已经将销售代码及其对应的目标包含在一个彼此对齐的数组中(salescode数组中的第一个元素的目标位于目标数组的第一个元素中)。输入成就,然后根据输入的销售代码将其除以数组中的目标。如果有条件查看个人获得何种激励,则将该值赋予4。

我需要的计算是:百分比=成就/目标 如何使它遍历salescode和targets数组(找到要计算的那一行)来计算以上内容?


salescode= [102,103,104,106,107,119,122,125,131,135,141,164,124,163,162]
targets=[3000000.00,4000000.00,3000000.00,3000000.00,3000000.00,4000000.00,2000000.00,2000000.00,2000000.00,3000000.00,2000000.00,3000000.00,2000000.00,2000000.00,2000000.00]

print(salescode)
print(targets)

sales=input("Enter\n")
achievement=input("Enter the Acheivement\n")

for sales in range(len(salescode)):
    percent=float(achievement)/float(targets)

    if  per>=2.50:
        print(" Incentive "+(float(achievement[x])*0.0225))
    elif  per>=2.00:
        print(" Incentive "+(float(achievement[x])*0.002))
    elif  per>=1.50:
        print(" Incentive "+(float(achievement[x])*0.0175))
    elif  per>=1.00:
        print(" Incentive "+(float(achievement[x])*0.001))
    elif  per<=0.99:
        print("Target Not Achieved")    

1 个答案:

答案 0 :(得分:0)

在用于循环的salescode中,您可以获得索引,并使用该索引可以获得目标值

salescode= [102,103,104,106,107,119,122,125,131,135,141,164,124,163,162]
targets=[3000000.00,4000000.00,3000000.00,3000000.00,3000000.00,4000000.00,2000000.00,2000000.00,2000000.00,3000000.00,2000000.00,3000000.00,2000000.00,2000000.00,2000000.00]

print(salescode)
print(targets)

sales=input("Enter\n")
achievement=input("Enter the Acheivement\n")

for sales in range(len(salescode)):
    getoutput =percetagefind(achievement,targets[sales])
    print(getoutput)   

功能

def percetagefind(achievement,target):
    per=float(achievement)/float(target)

    if  per>=2.50:
        return (" Incentive "+(float(achievement[x])*0.0225)
    elif  per>=2.00:
        return (" Incentive "+(float(achievement[x])*0.002))
    elif  per>=1.50:
        return (" Incentive "+(float(achievement[x])*0.0175))
    elif  per>=1.00:
        return (" Incentive "+(float(achievement[x])*0.001))
    elif  per<=0.99:
        return ("Target Not Achieved")