Python Object and Class - LearnHowToCode SarkariResult.com Interview Questions and Answers LearnHowToCodeOnline
Python Object and Class

Python Object and Class

Python Object and Class
Python is an object-oriented programming language. So, its main focus is on objects, unlike procedure-oriented programming languages which mainly focuses on functions.
In an object-oriented programming language, the object is simply a collection of data (variables) and methods (functions) that act on those data.

Python Class

A class is a blueprint for the object. Let's understand it by an example:
Suppose a class is a prototype of a building. A building contains all the details about the floor, doors, windows, etc. we can make other buildings (as many as we want) based on these details. So the building is a class and we can create many objects from a class.
An object is also called an instance of a class and the process of creating this object is known as instantiation.
Python classes contain all the standard features of Object Oriented Programming. A python class is a mixture of the class mechanism of C++ and Modula-3.

Python Object Class Example

class Student:  
   def __init__(self, rollno, name):  
      self.rollno = rollno  
      self.name = name  
   def displayStudent(self):  
      print "rollno : "self.rollno,  ", name: "self.name  
emp1 = Student(121"neha")  
emp2 = Student(122"siwa")  
emp1.displayStudent() 
emp2.displayStudent()  


About Mariano

I'm Ethan Mariano a software engineer by profession and reader/writter by passion.I have good understanding and knowledge of AngularJS, Database, javascript, web development, digital marketing and exploring other technologies related to Software development.

0 comments:

Featured post

Political Full Forms List

Acronym Full Form MLA Member of Legislative Assembly RSS Really Simple Syndication, Rashtriya Swayamsevak Sangh UNESCO United Nations E...

Powered by Blogger.