Question: For this exercise you will write a function that will evaluate any two Python objects in order to provide a numeric score indicating how closely
For this exercise you will write a function that will evaluate any two Python objects in order to provide a numeric score indicating how closely related they are. Create a file named
compare.py with a single function named compare. This function must take two arguments, and must return an integer satisfying the following requirements:
If the arguments contain references to the same object, return
If the arguments refer to different objects with same type and same value, return
If the arguments are the same type, but have different values, return
If the arguments are of different types, return
The following interaction provides some examples of the expected behavior.
#
#
#
comparea b # Same object.
compare # Different objects the same value.
compare # Same type, different values.
compared e # Different types.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
