Python is an object oriented programming language(Oop's concept). Almost everything in Python is an object,with methods.
Create a Class:
class MyClass: x = 5
Create Object:
p1 = MyClass() print(p1.x)
Object Methods:
Objects can also contain methods. Methods in objects are functions that belongs to the object.
class Person:
def __init__(self, name, age): self.name = name
self.age = age
def myfunc(self):
print("Hello my name is " + self.name)
p1 = Person("Prakash", 19)
p1.myfunc()
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Python Classes/Objects :
Python is an object oriented programming language(Oop's concept). Almost everything in Python is an object,with methods.
Create a Class:
Create Object:
Object Methods:
Objects can also contain methods. Methods in objects are functions that belongs to the object.
class Person: