Python Programming - Tricky Questions - Discussion

Discussion Forum : Tricky Questions - General Questions (Q.No. 38)
38.
What will be the output of the following Python code?
class MyClass:
    x = 10

obj = MyClass()
obj.x += 5
result = obj.x
print(result)
10
5
15
This code will result in an error.
Answer: Option
Explanation:
The attribute x is incremented by 5 using the instance obj.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.