Question: Task 3 Design the class Contacts so that the code produces the expected output. You are not allowed to change the given driver code below.

Task 3
Design the class "Contacts" so that the code produces the expected output. You are not
allowed to change the given driver code below.
# Driver code
names =["Emergency", "Father", "Bestie"]
numbers =["999","01xx23","01xx87","01xx65","01xx43"]
m1= Contacts(names, numbers)
print("Saved Contacts:", m1.contactDict)
print(
names.append("Mother")
numbers.pop()
m2= Contacts(names, numbers)
print("Saved Contacts:", m2.contactDict)
Output:
Contacts cannot be saved. Length Mismatch!
Saved Contacts: {}
Contacts saved successfully.
Saved Contacts: {'Emergency': '999', 'Father': '01xx23', 'Bestie': '01xx87', 'Mother':
'01xx65'}
Subtasks:
Suppose, after running the above code, you again write the following line:
m1= Contacts(names, numbers)
What will happen after executing this line?
Since m1 was already created in the 3rd line of the driver code, will the newly
created m1 have the same reference now? Explain by writing/modifying a few
lines of code.
[Hint: Store the previously created m1 in a temporary variable and compare it
with the new one.]
 Task 3 Design the class "Contacts" so that the code produces

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!