(Solved) : Part 2 Classes Section Working Classes Building Several Classes Solve Variety Problems Q4 Q38056871 . . .

Part 2: Classes In this section we will be working with classes - building several classes to solve a variety of problems Q4# YOUR CODE HERE raise NotImplementedError () assert OfficeHours assert OfficeHours (name, day, time,room) name Instructor]: # YOUR CODE HERE raise NotImplementedError) assert isinstance (all office_hours, list) assert len (all_office_hours)4 for

Part 2: Classes In this section we will be working with classes – building several classes to solve a variety of problems Q4 – Creating a Class (1 point) We can start with a class object to make a ‘schedule book’ for our course Office Hours Create a class called OfficeHours Class Attributes: course, which has the value “COGS18″ Instance Attibutes: name: string day :string time: string place : string Note: all these attributes should be passed into the_init__, and attached to the object in there . Method * check() o This method should print out information, to look something like o Prof s office hours are on Tuesday at 12:30 in CSB115. o Note that this should use the instance attributes to print out name, day, time & place of the particular instance [ ]: YOUR CODE HERE raise NotImplementedError () I 1 assert OfficeHours assert OfficeHours(‘name”day’, time’, room’) name”Instructor” day”Friday time”03:00″ place”CSB243″ test_oh-OfficeHours (name, day, time, place) assert isinstance (test oh, OfficeHours) # YOUR CODE HERE raise NotImplementedError () assert OfficeHours assert OfficeHours (name, “day, time,’room) name “Instructor” day”Friday time”03:00″ place = “CSB2 43″ test_ohOfficeHours (name, day, time, place) assert isinstance(test_oh, OfficeHours) assert test oh.course == ”COGS 18 ” assert test oh.namename assert test_oh.day -day assert test oh.time == time assert test oh.placeplace Here is a list of some office hours: . Professor Ellis Friday 3:00 in CSB 243 . Shreenivas Friday 6:00 in CSB 114 . Charles – Wednesday@ 1:00 in CSE Basement Benches . Myles – Monday 5:00 in Sun God Lounge Create a new instance of the OfficeHours class for each of the office hours listed above Then store each of these instances together in a list called all_office_hours . # YOUR CODE HERE raise NotImplementedError () assert isinstance (all _office_hours, list) assert len (all_office_hours)4 for item in all_office hours: assert isinstance (item, OfficeHours) ]: # YOUR CODE HERE raise NotImplementedError) assert isinstance (all office_hours, list) assert len (all_office_hours)4 for item in all office hours: assert isinstance(item, OfficeHours) assert item.name in [‘Professor Ellis’, ‘Shreenivas”, “Charles”, ‘Myles’ Now write a function called check_all that will take in a list of OfficeHour objects, and will call the check method on each one, using a loop to loop across each element in the input list. Call this function on your all_office_hours list to make sure that it works as expected. You should see that running this function prints out a string of information for each object, that looks like: Professor Ellis’s office hours are on Friday at 3:00 in CSB 243. Shreenivas’s office hours are on Friday at 6:00 in CSB 114 Charles ‘s office hours are on Wednesday at 1:00 in CSE Basement Benches. Myles’s office hours are on Monday at 5:00 in Sun God Lounge. ]: | # YOUR CODE HERE raise NotImplementedError ) assert callable (check_all) Show transcribed image text Part 2: Classes In this section we will be working with classes – building several classes to solve a variety of problems Q4 – Creating a Class (1 point) We can start with a class object to make a ‘schedule book’ for our course Office Hours Create a class called OfficeHours Class Attributes: course, which has the value “COGS18″ Instance Attibutes: name: string day :string time: string place : string Note: all these attributes should be passed into the_init__, and attached to the object in there . Method * check() o This method should print out information, to look something like o Prof s office hours are on Tuesday at 12:30 in CSB115. o Note that this should use the instance attributes to print out name, day, time & place of the particular instance [ ]: YOUR CODE HERE raise NotImplementedError () I 1 assert OfficeHours assert OfficeHours(‘name”day’, time’, room’) name”Instructor” day”Friday time”03:00″ place”CSB243″ test_oh-OfficeHours (name, day, time, place) assert isinstance (test oh, OfficeHours)
# YOUR CODE HERE raise NotImplementedError () assert OfficeHours assert OfficeHours (name, “day, time,’room) name “Instructor” day”Friday time”03:00″ place = “CSB2 43″ test_ohOfficeHours (name, day, time, place) assert isinstance(test_oh, OfficeHours) assert test oh.course == ”COGS 18 ” assert test oh.namename assert test_oh.day -day assert test oh.time == time assert test oh.placeplace Here is a list of some office hours: . Professor Ellis Friday 3:00 in CSB 243 . Shreenivas Friday 6:00 in CSB 114 . Charles – Wednesday@ 1:00 in CSE Basement Benches . Myles – Monday 5:00 in Sun God Lounge Create a new instance of the OfficeHours class for each of the office hours listed above Then store each of these instances together in a list called all_office_hours . # YOUR CODE HERE raise NotImplementedError () assert isinstance (all _office_hours, list) assert len (all_office_hours)4 for item in all_office hours: assert isinstance (item, OfficeHours)
]: # YOUR CODE HERE raise NotImplementedError) assert isinstance (all office_hours, list) assert len (all_office_hours)4 for item in all office hours: assert isinstance(item, OfficeHours) assert item.name in [‘Professor Ellis’, ‘Shreenivas”, “Charles”, ‘Myles’ Now write a function called check_all that will take in a list of OfficeHour objects, and will call the check method on each one, using a loop to loop across each element in the input list. Call this function on your all_office_hours list to make sure that it works as expected. You should see that running this function prints out a string of information for each object, that looks like: Professor Ellis’s office hours are on Friday at 3:00 in CSB 243. Shreenivas’s office hours are on Friday at 6:00 in CSB 114 Charles ‘s office hours are on Wednesday at 1:00 in CSE Basement Benches. Myles’s office hours are on Monday at 5:00 in Sun God Lounge. ]: | # YOUR CODE HERE raise NotImplementedError ) assert callable (check_all)

Expert Answer


Answer to Part 2: Classes In this section we will be working with classes – building several classes to solve a variety of problem…