Python Tutorial for Beginners

Python Object Methods Explained With Example

Understanding Object Method in Python

The variables that have a value or container are counted as an object in Python. Objects in themselves are a class that you can use for several programming purposes. The syntax of the object method in Python is object().

Code:

class Person1:

  def __init__():

    print(“python”)

  def my_func(self):

    print("hello”)

p = Person1()

p.my_func()
Output:
python
Hello

Video : https://youtu.be/qz_bnx84Xe0

Did you find this article helpful?