Vidyalelo
Python · Q42

Classes and Objects in Python

Programming · Python · question 42

Q42

What will be the output of the following Python code? def add(c,k): c.test=c.test+1 k=k+1 class A: def __init__(self): self.test = 0 def main(): Count=A() k=0 for i in range(0,25): add(Count,k) print("Count.test=", Count.test) print("k =", k) main()

A.
Exception is thrown
B.
Count.test=25
k=25
C.
Count.test=25
k=0
Answer
D.
Count.test=0
k=0

Answer: Option C

Solution

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