Python Classes and Object - General Pleasure

My dedication is to show general knowledge such as health, technology, resorts, cleanliness, popularity of traditional ways, how to make money online, and how to agree, publish our site, and up-to-date tutorials such as Excel, HTML, Powerpoint . we try to find good tips to show you, If you have any questions, please contact us my by e-mail Thank you for coming to our site. Thank you.

Home Top Ad

RESPONSIVE ADS HERE

Post Top Ad

Your Ad Spot

Sunday, July 5, 2020

Python Classes and Object

Python Classes and Object

1) Create a Class

    To create a class, use the Keyword Class

Example: 

Class Customer:
    y=20
print customer()

Output

<Class '--main--.customer'> 


2) Create Object

Example:  
Class Customer:
      y=20
object1=customer()

print(object1.y)

Output

20

 3)The __init__ () is Function

The Example above are classes and objects in their simplest from, and are not really useful in real application. To Understand the meaning of  classes we have to understand the build in  __init__ Function all classes have a function called __init__(), Which is always executed when the class is begin initialized.

Example: 
Class Customer:
      def __init(self,name,age,phone,position)
        self.name=name
        self.age=age
        self.phone=phone
        self.year=position
object1=customer("Vannaro",40,333,"IT")
print(object1.name)
print(object1.age)   
print(object1.phone)   
print(object1.position)

Output 
Vannaro
40
333
IT
              



Post Top Ad

Your Ad Spot