Question
Can you help me fix the error in my python code? Right now I am receiving the following error: The call utils.get_for_id( 'S00313' ,students) crashed.
Can you help me fix the error in my python code? Right now I am receiving the following error:
The call utils.get_for_id('S00313',students) crashed. Traceback (most recent call last): File "/home/codio/workspace/.guides/tests/step2/verifier.py", line 315, in grade_func1 row = utils.get_for_id(person,table) File "/home/codio/workspace/auditor/utils.py", line 177, in get_for_id ct = id.__class__._cache[id.db][table] AttributeError: type object 'str' has no attribute '_cache'
This is the function:
import utils
# CERTIFICATION CLASSIFICATIONS
# The certification of this pilot is unknown
PILOT_INVALID = -1
# A pilot that has joined the school, but has not soloed
PILOT_NOVICE= 0
# A pilot that has soloed but does not have a license
PILOT_STUDENT = 1
# A pilot that has a license, but has under 50 hours post license
PILOT_CERTIFIED = 2
# A pilot that 50 hours post license
PILOT_50_HOURS= 3
def get_certification(takeoff,student):
"""
Returns the certification classification for this student at the time of takeoff.
The certification is represented by an int, and must be the value PILOT_NOVICE,
PILOT_STUDENT, PILOT_CERTIFIED, PILOT_50_HOURS, or PILOT_INVALID. It is PILOT_50_HOURS
if the student has certified '50 Hours' before this flight takeoff.It is
PILOT_CERTIFIED if the student has a private license before this takeoff and
PILOT_STUDENT is the student has soloed before this takeoff.A pilot that has only
just joined the school is PILOT_NOVICE.If the flight takes place before the student
has even joined the school, the result is PILOT_INVALID.
Recall that a student is a 10-element list of strings.The first three elements are
the student's identifier, last name, and first name.The remaining elements are all
timestamps indicating the following in order: time joining the school, time of first
solo, time of private license, time of 50 hours certification, time of instrument
rating, time of advanced endorsement, and time of multiengine endorsement.
Parameter takeoff: The takeoff time of this flight
Precondition: takeoff is a datetime object
Parameter student: The student pilot
Precondition: student is 10-element list of strings representing a pilot
"""
cert_ = -1
for item in student[3:]:
if (item is not None) and (item != ''):
time = utils.str_to_time(item)
if time < takeoff and cert_ <= 2:
cert_ +=1
return cert_
This is an example of the data we have to pull from:
ID,LAST NAME,FIRST NAME,JOINED,SOLO,LICENSE,50 HOURS,INSTRUMENT,ADVANCED,MULTIENGINE
S00304,Wilson,Zachary,2015-01-07,2015-03-24,,,,,
S00308,Bates,Ashley,2015-01-09,2015-04-14,,,,,
S00309,Jones,Tammy,2015-01-10,2015-03-30,,,,,
S00311,Wheeler,Michael,2015-01-14,2015-04-08,,,,,
S00313,Kelley,Julie,2015-01-14,2015-03-02,,,,,
S00314,Barrett,Tammy,2015-01-18,2015-06-13,,,,,
S00315,Murray,Donald,2015-01-20,2015-08-29,,,,,
S00319,Holland,Tiffany,2015-01-25,2015-03-09,,,,,
S00321,Coleman,Judith,2015-01-28,2015-07-05,,,,,
S00324,Moreno,Harold,2015-01-29,2015-04-11,,,,,
S00326,Aguilar,Jacob,2015-01-31,2015-03-27,,,,,
S00328,Pearson,Ethan,2015-02-10,2015-03-30,,,,,
S00329,Carpenter,Martha,2015-02-10,2015-09-12,,,,,
S00331,Wilson,Ruth,2015-02-20,2016-02-14,,,,,
S00335,Campbell,Ronald,2015-02-21,2015-04-10,,,,,
S00336,Murphy,Deborah,2015-02-22,2015-08-16,,,,,
S00337,Reid,Ralph,2015-02-24,2015-05-07,,,,,
S00341,Torres,Harold,2015-02-24,2015-04-10,,,,,
S00342,Marshall,Emma,2015-02-24,2015-10-25,,,,,
S00343,Richards,Sean,2015-03-02,2015-11-07,,,,,
S00347,Dixon,Sean,2015-03-04,2015-06-02,,,,,
S00350,Dixon,Henry,2015-03-04,2015-05-28,2015-08-11,2015-12-22,2015-12-22,,
S00352,Munoz,Louis,2015-03-09,2015-08-01,,,,,
S00353,Pena,Christopher,2015-03-11,2015-04-29,2015-06-05,2015-09-08,,,
S00354,Morales,Roy,2015-03-15,2015-04-30,,,,,
S00358,Schultz,Louis,2015-03-15,2016-03-06,,,,,
S00362,Kim,Nathan,2015-03-16,2015-06-23,2015-08-11,2016-01-05,,,
S00365,Pearson,Jose,2015-03-19,2015-08-30,,,,,
S00366,Hayes,David,2015-03-21,2015-12-13,,,,,
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started