Python Programming - Classes - Discussion

Discussion Forum : Classes - General Questions (Q.No. 3)
3.
How can you create a class variable?
Define it inside a method with the keyword var.
Declare it outside any method in the class with the keyword static.
Use the self keyword inside a method.
Define it inside the constructor using __init__.
Answer: Option
Explanation:
Class variables in Python are declared outside any method in the class and are shared by all instances of the class. They are typically defined with the static keyword.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.