Vidyalelo
Python · Q97

MCQs for Python Strings: Exam

Programming · Python · question 97

Q97

What will be the output of the following Python 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
Answer
C.
Peter Smith
D.
John Smith

Answer: Option B

Solution

Answer: Option B
No explanation is given for this question Let's Discuss on Board