Blog Introductions
In this blog contains tutorials about HTML Tutorials, Python Tutorials, CSS Tutorials, How to, PHP Tutorials, Java Tutorials, C++ Tutorials, Tutorials, Examples, Source code,Learning,
Tips and Software development services. Python OOP and Python object orriented programing | Python tutorials Bestitworriors
Python object orriented programing
Python OOP and Python object orriented programing | Python tutorials Bestitworriors - OOP stand for object orriented programin.In object oriented programin we work with object.Object define as any things which have some properties and functions.For exemple A car is a object which have properties like color,weight,length etc and which have functions like drive and stop etc.
Some Key Points of Python OOP
- OOP stands for object orriented programing
- In object orriented programing we work on object
- Object which have some properties and functions
- We create class for working an object
- Class contain properties and methods
- Class properties and methods can private,public or protected
Code
class FirstClass:
x = 5
p1 = FirstClass()
print(p1.x)
class SecondClass:
def __init__(self, name, age):
self.name = name
self.age = age
p2 = SecondClass("Bestitworrior", 36)
print(p2.name)
print(p2.age)
class ThirdClass:
def __init__(self, name, age):
self.name = name
self.age = age
def classfunction(self):
print("Hello my name is " + self.name)
p3 = ThirdClass("Bestitworrior", 36)
p3.classfunction()
p3.age = 40
del p3.age
del p3
OutPut
5
Bestitworrior
36
Hello my name is Bestitworrior
Bestitworrior
36
Hello my name is Bestitworrior
0 Comments