Question: A 'dictionary' is a data structure that stores each element in a list as a pair, key:value. for instance, you could have a dictionary of

A 'dictionary' is a data structure that stores each element in a list as a pair, key:value.

for instance, you could have a dictionary of pairs consisting of a persons name and their favorite numbers.

my_dictionary = {"Bob":[3, 45, 6] , "Tina":[32, 5, 9], "Carl":[6, 77, 12]}

You will write code that works with 3 dictionaries simultaneously.

First is a dictionary of instructors (called instructors) and the classes they teach.

Second is a dictionary consisting of students (called students) and classes they are taking.

Third is a dictionary called teaches that consists of only a single entry ["instructor":"student"]

Your task is to write a function called classDirectory that takes three inputs: the dictionaries instructors, students, and teaches. The return should be a boolean. TRUE if teaches is true, else FALSE.

In other words if there is a teacher named Smith and a student named Jones and Smith teaches Jones, then [Smith:Jones] should return TRUE.

Logical Constraints:

  • An instructor can teach only 1 class.
  • Students can enroll in multiple classes.
  • teaches will contain a single entry of instructor and student.

Sample Input:

instructors = { "chan": "math273", "patel": "ee222", "grossman": "cs301", "dirk": "cs4253", "bo": "cs5454", }

students = { "kevin": "math273", "juana": ["cs301","math273"], "kiko": ["cs301","math273"], "nim":["cs5454","ee222"], "addzy": ["cs5454","math273"], "dorsey": "cs5454", }

- Test case 1

teaches = { "chan":"juana", }

- Test case 2

teaches = { "patel":"addzy", }

Sample Output :

1. True 2. False Write your code under the classDirectory() function only. Please DO NOT change the names of file, class or function. You may, however, rename the parameters (except the self parameter) but NOT reorder them.

#DO NOT CHANGE THE NAMES OF THE FILE, CLASS or METHOD

class LogicProgramming(): def classDirectory(self,instructor, student, teaches):

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!