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

Part III: Unfair Hiring System (20 points) Write a function unfair hiring system

ID: 3585612 • Letter: P

Question

Part III: Unfair Hiring System (20 points) Write a function unfair hiring system (0 that takes the following arguments, in this order. 11 applications: a list of strings containing some combination of 'strong'.'Fair ', 'Poor ' and "Disaster ' . If the current application is 'poor' and his current mood is less than 75% of his starting mood level then 2. mood: a positive integer that indicates the starting mood of the recruiter. A higher value increases his reject the application and subtracts from his current mood. chances of hiring weaker applicants, . If the current application is 'Disaster then reject the application and subtract 10 from his current A recruiter wants to hire people for his firm. He is given a list of applications to look at and needs to make mood. 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 starts off at a moodiness level of mood, but as time progresses, he starts to feel . Every application he checks decreases his mood by 1, regardless of how good the application is. exhausted, and judge applications more harshly. If his mood drops to 0 then he stops recruiting and starts rejecting Examples : all remaining applicants. Your function must mimic the scenario above. The recruiter analyzes each application in turm from the list as application1 = [' Strong ', 'Fair ', 'Disaster ' follows: application2 - application3 - 'Disaster', 'Poor ', 'Disaster ', 'Disaster ", 'Disaster , • If the current application is strong then append the index of the application to the list you will return "Poor ', 'Disaster ", "Poor' and add 2 to his current mood. Function Call Return Value • If the current application is 'Fair and his current mood is 50% or more of his starting mood level then unfair.hiring system (applications 1, 100 ) , 1) append the index of the application and add 1 to his current mood. unfair . hiring -system applications 2,50 ) ) • If the current application is 'Fair" and his current mood is less than sort % of his starting mood level then unfair.hiring.system applications 3 , 200 ) (1,5] reject the application and subtract 2 from his current mood. • If the current application is 'Poor and his current mood is 75% or more of his starting mood level then append the index of the application and subtract from his current mood. CSE 101 - Fall 2017 Lab M4 Page 3

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))