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 0.
If the arguments refer to different objects with same type and same value, return 1.
If the arguments are the same type, but have different values, return 2.
If the arguments are of different types, return 3.
The following interaction provides some examples of the expected behavior.
a=#1
>b=a
"#"
c+=1
d="#2"
=>e=7
> compare(a, b) # Same object.
0
compare (a,c) # Different objects the same value.
1
compare (c,d) # Same type, different values.
2
> compare(d, e) # Different types.
 For this exercise you will write a function that will evaluate

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!