Candidate qualifications

Assignment

Create a function that can be used for recruiting a person for a specific job function.  This function should take the applicants name, GPA, and major.

The function should return True if the applicant meets the criteria and False if they do not.  In addition, the function should return a message indicating reasons that a candidate is not acceptable.

The acceptableness and message should be returned in a tuple.

Here are the criteria:

  1. GPA >=3.2.  If GPA is too low the message is “You should have studied harder in school, <name>.”
  1. Major of Digital Forensics (DF) or Computer Science (CS).  You should accept either the full names or the abbreviations regardless of what capitalization was used.  If the major is not acceptable the message is

“Sorry, <name>, your area of study does not match our current needs.”

Here is an example of how this function would be used:

applicants=[…list of dictionaries…]

for applicant in applicants:

yesNo=acceptable(applicant[‘name’] , applicant[‘gpa’], applicant[‘major’])

ifyesNo[0]:

print(‘Congratulations, {}! You have made it past the first screening’.format(applicant[‘name’]))

else:

print(“I’m sorry, {}.  You are not moving on for the following reasons: {}” % (applicant[‘name’], yesNo[1]))

Solution 

acceptable.py 

def acceptable(name, gpa, major):

gpa_bool = True

major_bool = True

acceptable_majors = [‘major of digital forensics’, ‘computer science’, ‘df’, ‘cs’]

ifgpa<3.2:

gpa_bool = False

ifmajor.lower() not in acceptable_majors:

major_bool = False

ifgpa_bool and major_bool:

return True, ”

elif not gpa_bool:

return False, “You should have studied harder in school, “+name+”.”

else:

return False, “Sorry, ” + name + “, your area of study does not match our current needs.”