Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Python programming Part III: Unfair Hiring System (20 points) Write a function u

ID: 3586995 • Letter: P

Question



Python programming

Part III: Unfair Hiring System (20 points) Write a function unfair hiring.system) that takes the following arguments, in this order 1. applications: a list of strings containing some combination of Strong'. Fair Poor' and Disaster 2. mood: a positive integer that indicates the starting mood of the recruiter. A higher value increases his chances of hiring weaker applicants. A recruiter wants to hire people for his firm. He is given a list of applications to look at and needs to make a list of applicants he wants to hire. The function will return a list of the indexes of people hired to be from the applications list. He stants off at a moodiness level of mood, but as time progresses, he starts to feel exhausted, and judge applications more harshly. If his mood drops to 0 then he stops recruiting and starts rejecting all remaining applicants. Your function must mimic the scenario above. The recruiter analyzes each application in turn from the list as . If the current application is ' St rong' then append the index of the application to the list you will return · If the current application is , Fair, and his current mood is 50% or more of his starting mood level then . If the current application is , Fair, and his current mood is less than 50% of his starting mood level then · If the current application is poor, and his current mood is 75% or more of his starting mood level then follows: and add 2 to his current mood. append the index of the application and add I to his current mood reject the application and subtract 2 from his current mood append the index of the application and subtract I from his current mood CSE 101 - Fall 2017 Lab #4 Page 3 · If the current application is , Poor, and his current mood is less than 75% of his starting mood level then reject the application and subtract 5 from his current mood. . If the current application is Disaster then reject the application and subtract 10 from his current mood. . Every application he checks decreases his mood by 1, regardless of how good the application is Examples: application I' Strong',FairDisaster' 1

Explanation / Answer

def unfair_hiring_system(applications,mood):
    list = []
    start = mood
    for i in range(len(applications)):
        mood = mood -1
        if applications[i] == 'Strong':
           list.append(i)
           mood = mood + 2
        if applications[i] == 'Fair':
           if mood >= 0.5 * start:
              list.append(i)
              mood = mood + 1
           else:
              mood = mood - 2
        if applications[i] == 'Poor':
           if mood >= 0.75 * start:
              list.append(i)
              mood = mood - 1
           else:
              mood = mood - 5
        if applications[i] == 'Disaster':
           mood = mood - 10
    return list


application1 = ['Strong', 'Fair', 'Disaster']
application2 = []
application3 = ['Disaster','Poor','Disaster','Disaster', 'Disaster','Poor','Disaster','Poor']

print(unfair_hiring_system(application1,100))
print(unfair_hiring_system(application2,50))
print(unfair_hiring_system(application3,200))