Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions

Question

8. Provide recommendations for how to manage knowledge.

Answered: 1 week ago