what is instance in python code example
Example 1: what is a ython instance
An object belonging to a class. e.g. if you had an Employee class, each
individual employee would be an instance of the Employee class
Example 2: instance method in python
# Instance Method Example in Python
class Student:
def __init__(self, a, b):
self.a = a
self.b = b
def avg(self):
return (self.a + self.b) / 2
s1 = Student(10, 20)
print( s1.avg() )