Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#Imagine you're writing a program to check if a person is #available at a certain time. # #To do this, you want to write a

#Imagine you're writing a program to check if a person is

#available at a certain time.

#

#To do this, you want to write a function called

#check_availability. check_availability will have two

#parameters: a list of instances of the Meeting class, and

#proposed_time, a particular date and time.

#

#check_availability should return True (meaning the person

#is available) if there are no instances of Meeting that

#conflict with the proposed_time. In other words, it should

#return False if proposed_time is between the start_time and

#end_time for any meeting in the list of meetings.

#

#The Meeting class is defined below. It has two attributes:

#start_time and end_time. start_time is an instance of the

#datetime class showing when the meeting starts, and

#end_time is an instance of the datetime class indicating

#when the meeting ends.

#

#Hint: Instances of the datetime have at least six

#attributes: year, month, day, hour, minute, and second.

#

#Hint 2: Comparison operators work with instances of the

#datetime class. time_1 < time_2 will be True if time_1 is

#earlier than time_2, and False otherwise.

#

#You should not assume that the list is sorted.

#Here is our definition of the Meeting class:

from datetime import datetime

class Meeting:

def __init__(self, start_time, end_time):

self.start_time = start_time

self.end_time = end_time

#Write your function here!

#Below are some lines of code that will test your function.

#You can change the value of the variable(s) to test your

#function with different inputs.

#

#If your function works correctly, this will originally

#print: True, then False

meetings = [Meeting(datetime(2018, 8, 1, 9, 0, 0), datetime(2018, 8, 1, 11, 0, 0)),

Meeting(datetime(2018, 8, 1, 15, 0, 0), datetime(2018, 8, 1, 16, 0, 0)),

Meeting(datetime(2018, 8, 2, 9, 0, 0), datetime(2018, 8, 2, 10, 0, 0))]

print(check_availability(meetings, datetime(2018, 8, 1, 12, 0, 0)))

print(check_availability(meetings, datetime(2018, 8, 1, 10, 0, 0)))

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

Microsoft Visual Basic 2008 Comprehensive Concepts And Techniques

Authors: Gary B. Shelly, Corinne Hoisington

1st Edition

1423927168, 978-1423927167

More Books

Students also viewed these Databases questions

Question

Anna gathers leaves that have fallen from a neighbor

Answered: 1 week ago

Question

Understanding Groups

Answered: 1 week ago