adplus-dvertising
frame-decoration

Question

What is the output of the following code ?
class Name:
    def __init__(self, firstName, mi, lastName):
        self.firstName = firstName
        self.mi = mi
        self.lastName = lastName
 
firstName = "John"
name = Name(firstName, 'F', "Smith")
firstName = "Peter"
name.lastName = "Pan"
print(name.firstName, name.lastName)

a.

Peter Pan

b.

John Pan

c.

Peter Smith

d.

John Smith

Posted under Python

Answer: (b).John Pan

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of the following code ?