Respuesta :
Answer:
Here is the function same_person that takes two instances of Person as arguments i.e. p1 and p2 and returns True if they are the same Person, False otherwise.
def same_person(p1, p2): #definition of function same_person that takes two parameters p1 and p2
if p1.GTID==p2.GTID: # if the two instances of Person have same GTID
return True #returns true if above condition evaluates to true
else: #if the two instances of Person do not have same GTID
return False #returns false when two persons have different GTID
Explanation:
person1 = Person("David Joyner", 30, 901234567) #first instance of Person
person2 = Person("D. Joyner", 29, 901234567) #second instance of Person
person3 = Person("David Joyner", 30, 903987654) #third instance of Person
print(same_person(person1, person2)) #calls same_person method by passing person1 and person2 instance of Person to check if they are same
print(same_person(person1, person3)) #calls same_person method by passing person1 and person3 instance of Person to check if they are same
The function works as follows:
For function call print(same_person(person1, person2))
The GTID of person1 is 901234567 and that of person2 is 901234567
If condition if p1.GTID==p2.GTID in the function same_person checks if the GTID of person1 is equal to the GTID of person2. This condition evaluates to true because GTID of person1 = 901234567 and GTID of person2 = 901234567
So the output is:
True
For function call print(same_person(person1, person3))
The GTID of person1 is 901234567 and that of person3 is 903987654
If condition if p1.GTID==p2.GTID in the function same_person checks if the GTID of person1 is equal to the GTID of person3. This condition evaluates to false because GTID of person1 = 901234567 and GTID of person2 = 903987654 and they are not equal
So the output is:
False
The complete program along with its output is attached in a screenshot.