class Car: wheels = 4 # <- Class variable def __init__(self, name): self.name = name # <- Instance variable
Instance Variable in Python is the value varies from object to object.
class Car:
wheels = 4 # <- Class variable
def __init__(self, name):
self.name = name # <- Instance variable
# Python instance variables can have different values across multiple instances of a class.
# Class variables share the same value among all instances of the class. The value of instance
# variables can differ across each instance of a class. Class variables can only be assigned
# when a class has been defined.