Posts

Showing posts from January, 2021

Concept of Class, Method and Objects

Class The class can be defined as a collection of objects. It is a logical entity that has some specific attributes and methods. For example: if you have an employee class, then it should contain an attribute and method, i.e. an email id, name, age, salary, etc. Syntax for creating Class class ClassName: {Statement Here} Let's go through the example Suppose Employee is a class. Employee Has an atttributes Name, email, Address and Salary. class Employee: # Here __init__() is a constructor.Constructors are generally used for instantiating an object. The task of constructors is to initialize(assign values) to the data members of the class when an object of class is created. In Python the __init__() method is called the constructor and is always called when an object is created. def __init__(self): Objects The object is an entity that has state and behavior. It may be any real-world object like the mouse, keyboard, chair, tab...

Introduction to OOPS

About OOPS Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which can contain data and code: data in the form of fields (often known as attributes or properties), and code, in the form of procedures (often known as methods). A feature of objects is that an object's own procedures can access and often modify the data fields of itself (objects have a notion of this or self). In OOP, computer programs are designed by making them out of objects that interact with one another. OOP languages are diverse, but the most popular ones are class-based, meaning that objects are instances of classes, which also determine their types. Uses of OOPS OOP models complex things as reproducible, simple structures Reusable, OOP objects can be used across programs Allows for class-specific behavior through polymorphism Easier to debug, classes often contain all applicable information to them Secure, protects information through e...