Question: Python Programming The file pilots.csv is a list of all pilots in the school, together with the dates that they earned these certifications, ratings, and

Python Programming

The file pilots.csv is a list of all pilots in the school, together with the dates that they earned these certifications, ratings, and endorsements. Specifically, this CSV file has the following header: ID LASTNAME FIRSTNAME JOINED SOLO LICENSE 50 HOURS INSTRUMENT ADVANCED MULTIENGINE

The first three columns are strings, while all other columns are dates.

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

# Implement function here

Function to convert takeoff time from string to datetime object is below in bold, you must use this function only (from utils import):

def str_to_time(timestamp,tz=None):

try: result = parse(timestamp) if result.tzinfo is None and tz is None: return result elif result.tzinfo is None and type(tz) == str: time1 = pytz.timezone(tz) e = time1.localize(result) return e elif result.tzinfo is not None and tz is None: return result elif result.tzinfo is None and tz is not None: g = result.replace(tzinfo=tz) return g elif result.tzinfo is not None and tz is not None: h = result.replace() return h except ValueError: return None

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!