Blog Details

img
Data Science

what is python object class

Spoke Right / 14 Nov, 2023

Python object class

Like Java and C++, Python is also based on OOPs Concept, i.e, Python is an object-oriented programming language which uses classes and objects for computations.

Python Class:

A collection of Objects is termed as Class in OOPs concept. Every class has its own unique and distinguishable attributes and methods.

Syntax:

class ClassName:

 

    . 

    . 

    . 

     


Python Object:

Anything that has state and behavior can be termed as an Object, be it physical or logical. An Object is an entity mentioned in OOPs concept and is frequently found in Python codes.

Creating an object in Python is similar as calling a function. The objects attributes can then be accessed by using the object name prefix.


Example:

class Employees(): 
   def __init__(self, Name, Salary): 
       self.Name = Name
       self.Salary = Salary
 
   def details(self): 
       print "Employee Name : ", self.Name
       print "Employee Salary: ", self.Salary
       print "\n"
 
first = Employees("Khush", 10000) 
second = Employees("Raam", 20000)
third = Employees("Lav", 10000)
fourth = Employees("Sita", 30000)
fifth = Employees("Lucky", 50000)
 
first.details() 
second.details() 
third.details()
fourth.details()
fifth.details()

0 comments

Warning: PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20210902/imagick.so (/usr/local/lib/php/extensions/no-debug-non-zts-20210902/imagick.so: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20210902/imagick.so.so (/usr/local/lib/php/extensions/no-debug-non-zts-20210902/imagick.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0