PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYAMaulik Borsaniya
Classes and Object-oriented Programming:
Classes: Creating a Class, The Self Variable, Constructor, Types of Variables, Namespaces, Types of Methods (Instance Methods, Class Methods, Static Methods), Passing Members of One Class to Another Class, Inner Classes
Inheritance and Polymorphism: Constructors in Inheritance, Overriding Super Class Constructors and Methods, The super() Method, Types of Inheritance, Single Inheritance, Multiple Inheritance, Method Resolution Order (MRO), Polymorphism, Duck Typing Philosophy of Python, Operator Overloading, Method Overloading, Method Overriding
Abstract Classes and Interfaces: Abstract Method and Abstract Class, Interfaces in Python, Abstract Classes vs. Interfaces,
A class is a code template for creating objects. Objects have member variables and have behaviour associated with them. In python a class is created by the keyword class.
An object is created using the constructor of the class. This object will then be called the instance of the class.
Inheritance and Polymorphism in Python. Inheritance is a mechanism which allows us to create a new class – known as child class – that is based upon an existing class – the parent class, by adding new attributes and methods on top of the existing class.
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYAMaulik Borsaniya
Classes and Object-oriented Programming:
Classes: Creating a Class, The Self Variable, Constructor, Types of Variables, Namespaces, Types of Methods (Instance Methods, Class Methods, Static Methods), Passing Members of One Class to Another Class, Inner Classes
Inheritance and Polymorphism: Constructors in Inheritance, Overriding Super Class Constructors and Methods, The super() Method, Types of Inheritance, Single Inheritance, Multiple Inheritance, Method Resolution Order (MRO), Polymorphism, Duck Typing Philosophy of Python, Operator Overloading, Method Overloading, Method Overriding
Abstract Classes and Interfaces: Abstract Method and Abstract Class, Interfaces in Python, Abstract Classes vs. Interfaces,
A class is a code template for creating objects. Objects have member variables and have behaviour associated with them. In python a class is created by the keyword class.
An object is created using the constructor of the class. This object will then be called the instance of the class.
Inheritance and Polymorphism in Python. Inheritance is a mechanism which allows us to create a new class – known as child class – that is based upon an existing class – the parent class, by adding new attributes and methods on top of the existing class.
import in python is similar to #include header_file in C/C++. Python modules can get access to code from another module by importing the file/function using import. The import statement is the most common way of invoking the import machinery, but it is not the only way. import module_name .When the import is used, it searches for the module initially in the local scope by calling __import__() function. The value returned by the function is then reflected in the output of the initial code.
This presentation educates you about objectives of python with example syntax, OOP Terminology, Creating Classes, Creating Instance Objects, Accessing Attributes and Built-In Class Attributes.
Object-oriented programming (OOP) is a paradigm in programming centered around the concept of "objects." In Python, OOP allows you to create and organize code using classes and objects, enabling you to structure your programs more efficiently, manage complexity, and promote code reusability.The concept of bundling data (attributes) and the methods that work on the data within a single unit (a class). It restricts direct access to some of the object's components and hides the internal state.Focusing on essential features by hiding complex implementation details. It enables working with objects at a higher level of abstraction without worrying about internal complexities.
Python's object-oriented programming provides a powerful way to structure code, promote code reuse, and build more modular and maintainable applications by leveraging these concepts effectively.
Advanced Flow Concepts Every Developer Should KnowPeter Caitens
Tim Combridge from Sensible Giraffe and Salesforce Ben presents some important tips that all developers should know when dealing with Flows in Salesforce.
import in python is similar to #include header_file in C/C++. Python modules can get access to code from another module by importing the file/function using import. The import statement is the most common way of invoking the import machinery, but it is not the only way. import module_name .When the import is used, it searches for the module initially in the local scope by calling __import__() function. The value returned by the function is then reflected in the output of the initial code.
This presentation educates you about objectives of python with example syntax, OOP Terminology, Creating Classes, Creating Instance Objects, Accessing Attributes and Built-In Class Attributes.
Object-oriented programming (OOP) is a paradigm in programming centered around the concept of "objects." In Python, OOP allows you to create and organize code using classes and objects, enabling you to structure your programs more efficiently, manage complexity, and promote code reusability.The concept of bundling data (attributes) and the methods that work on the data within a single unit (a class). It restricts direct access to some of the object's components and hides the internal state.Focusing on essential features by hiding complex implementation details. It enables working with objects at a higher level of abstraction without worrying about internal complexities.
Python's object-oriented programming provides a powerful way to structure code, promote code reuse, and build more modular and maintainable applications by leveraging these concepts effectively.
Advanced Flow Concepts Every Developer Should KnowPeter Caitens
Tim Combridge from Sensible Giraffe and Salesforce Ben presents some important tips that all developers should know when dealing with Flows in Salesforce.
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Shahin Sheidaei
Games are powerful teaching tools, fostering hands-on engagement and fun. But they require careful consideration to succeed. Join me to explore factors in running and selecting games, ensuring they serve as effective teaching tools. Learn to maintain focus on learning objectives while playing, and how to measure the ROI of gaming in education. Discover strategies for pitching gaming to leadership. This session offers insights, tips, and examples for coaches, team leads, and enterprise leaders seeking to teach from simple to complex concepts.
Accelerate Enterprise Software Engineering with PlatformlessWSO2
Key takeaways:
Challenges of building platforms and the benefits of platformless.
Key principles of platformless, including API-first, cloud-native middleware, platform engineering, and developer experience.
How Choreo enables the platformless experience.
How key concepts like application architecture, domain-driven design, zero trust, and cell-based architecture are inherently a part of Choreo.
Demo of an end-to-end app built and deployed on Choreo.
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTier1 app
Even though at surface level ‘java.lang.OutOfMemoryError’ appears as one single error; underlyingly there are 9 types of OutOfMemoryError. Each type of OutOfMemoryError has different causes, diagnosis approaches and solutions. This session equips you with the knowledge, tools, and techniques needed to troubleshoot and conquer OutOfMemoryError in all its forms, ensuring smoother, more efficient Java applications.
Developing Distributed High-performance Computing Capabilities of an Open Sci...Globus
COVID-19 had an unprecedented impact on scientific collaboration. The pandemic and its broad response from the scientific community has forged new relationships among public health practitioners, mathematical modelers, and scientific computing specialists, while revealing critical gaps in exploiting advanced computing systems to support urgent decision making. Informed by our team’s work in applying high-performance computing in support of public health decision makers during the COVID-19 pandemic, we present how Globus technologies are enabling the development of an open science platform for robust epidemic analysis, with the goal of collaborative, secure, distributed, on-demand, and fast time-to-solution analyses to support public health.
Designing for Privacy in Amazon Web ServicesKrzysztofKkol1
Data privacy is one of the most critical issues that businesses face. This presentation shares insights on the principles and best practices for ensuring the resilience and security of your workload.
Drawing on a real-life project from the HR industry, the various challenges will be demonstrated: data protection, self-healing, business continuity, security, and transparency of data processing. This systematized approach allowed to create a secure AWS cloud infrastructure that not only met strict compliance rules but also exceeded the client's expectations.
In software engineering, the right architecture is essential for robust, scalable platforms. Wix has undergone a pivotal shift from event sourcing to a CRUD-based model for its microservices. This talk will chart the course of this pivotal journey.
Event sourcing, which records state changes as immutable events, provided robust auditing and "time travel" debugging for Wix Stores' microservices. Despite its benefits, the complexity it introduced in state management slowed development. Wix responded by adopting a simpler, unified CRUD model. This talk will explore the challenges of event sourcing and the advantages of Wix's new "CRUD on steroids" approach, which streamlines API integration and domain event management while preserving data integrity and system resilience.
Participants will gain valuable insights into Wix's strategies for ensuring atomicity in database updates and event production, as well as caching, materialization, and performance optimization techniques within a distributed system.
Join us to discover how Wix has mastered the art of balancing simplicity and extensibility, and learn how the re-adoption of the modest CRUD has turbocharged their development velocity, resilience, and scalability in a high-growth environment.
Unleash Unlimited Potential with One-Time Purchase
BoxLang is more than just a language; it's a community. By choosing a Visionary License, you're not just investing in your success, you're actively contributing to the ongoing development and support of BoxLang.
Quarkus Hidden and Forbidden ExtensionsMax Andersen
Quarkus has a vast extension ecosystem and is known for its subsonic and subatomic feature set. Some of these features are not as well known, and some extensions are less talked about, but that does not make them less interesting - quite the opposite.
Come join this talk to see some tips and tricks for using Quarkus and some of the lesser known features, extensions and development techniques.
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?XfilesPro
Worried about document security while sharing them in Salesforce? Fret no more! Here are the top-notch security standards XfilesPro upholds to ensure strong security for your Salesforce documents while sharing with internal or external people.
To learn more, read the blog: https://www.xfilespro.com/how-does-xfilespro-make-document-sharing-secure-and-seamless-in-salesforce/
We describe the deployment and use of Globus Compute for remote computation. This content is aimed at researchers who wish to compute on remote resources using a unified programming interface, as well as system administrators who will deploy and operate Globus Compute services on their research computing infrastructure.
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Globus
The Earth System Grid Federation (ESGF) is a global network of data servers that archives and distributes the planet’s largest collection of Earth system model output for thousands of climate and environmental scientists worldwide. Many of these petabyte-scale data archives are located in proximity to large high-performance computing (HPC) or cloud computing resources, but the primary workflow for data users consists of transferring data, and applying computations on a different system. As a part of the ESGF 2.0 US project (funded by the United States Department of Energy Office of Science), we developed pre-defined data workflows, which can be run on-demand, capable of applying many data reduction and data analysis to the large ESGF data archives, transferring only the resultant analysis (ex. visualizations, smaller data files). In this talk, we will showcase a few of these workflows, highlighting how Globus Flows can be used for petabyte-scale climate analysis.
A Comprehensive Look at Generative AI in Retail App Testing.pdfkalichargn70th171
Traditional software testing methods are being challenged in retail, where customer expectations and technological advancements continually shape the landscape. Enter generative AI—a transformative subset of artificial intelligence technologies poised to revolutionize software testing.
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisGlobus
JASMIN is the UK’s high-performance data analysis platform for environmental science, operated by STFC on behalf of the UK Natural Environment Research Council (NERC). In addition to its role in hosting the CEDA Archive (NERC’s long-term repository for climate, atmospheric science & Earth observation data in the UK), JASMIN provides a collaborative platform to a community of around 2,000 scientists in the UK and beyond, providing nearly 400 environmental science projects with working space, compute resources and tools to facilitate their work. High-performance data transfer into and out of JASMIN has always been a key feature, with many scientists bringing model outputs from supercomputers elsewhere in the UK, to analyse against observational or other model data in the CEDA Archive. A growing number of JASMIN users are now realising the benefits of using the Globus service to provide reliable and efficient data movement and other tasks in this and other contexts. Further use cases involve long-distance (intercontinental) transfers to and from JASMIN, and collecting results from a mobile atmospheric radar system, pushing data to JASMIN via a lightweight Globus deployment. We provide details of how Globus fits into our current infrastructure, our experience of the recent migration to GCSv5.4, and of our interest in developing use of the wider ecosystem of Globus services for the benefit of our user community.
Check out the webinar slides to learn more about how XfilesPro transforms Salesforce document management by leveraging its world-class applications. For more details, please connect with sales@xfilespro.com
If you want to watch the on-demand webinar, please click here: https://www.xfilespro.com/webinars/salesforce-document-management-2-0-smarter-faster-better/
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns
Unlocking Business Potential: Tailored Technology Solutions by Prosigns
Discover how Prosigns, a leading technology solutions provider, partners with businesses to drive innovation and success. Our presentation showcases our comprehensive range of services, including custom software development, web and mobile app development, AI & ML solutions, blockchain integration, DevOps services, and Microsoft Dynamics 365 support.
Custom Software Development: Prosigns specializes in creating bespoke software solutions that cater to your unique business needs. Our team of experts works closely with you to understand your requirements and deliver tailor-made software that enhances efficiency and drives growth.
Web and Mobile App Development: From responsive websites to intuitive mobile applications, Prosigns develops cutting-edge solutions that engage users and deliver seamless experiences across devices.
AI & ML Solutions: Harnessing the power of Artificial Intelligence and Machine Learning, Prosigns provides smart solutions that automate processes, provide valuable insights, and drive informed decision-making.
Blockchain Integration: Prosigns offers comprehensive blockchain solutions, including development, integration, and consulting services, enabling businesses to leverage blockchain technology for enhanced security, transparency, and efficiency.
DevOps Services: Prosigns' DevOps services streamline development and operations processes, ensuring faster and more reliable software delivery through automation and continuous integration.
Microsoft Dynamics 365 Support: Prosigns provides comprehensive support and maintenance services for Microsoft Dynamics 365, ensuring your system is always up-to-date, secure, and running smoothly.
Learn how our collaborative approach and dedication to excellence help businesses achieve their goals and stay ahead in today's digital landscape. From concept to deployment, Prosigns is your trusted partner for transforming ideas into reality and unlocking the full potential of your business.
Join us on a journey of innovation and growth. Let's partner for success with Prosigns.
Your Digital Assistant.
Making complex approach simple. Straightforward process saves time. No more waiting to connect with people that matter to you. Safety first is not a cliché - Securely protect information in cloud storage to prevent any third party from accessing data.
Would you rather make your visitors feel burdened by making them wait? Or choose VizMan for a stress-free experience? VizMan is an automated visitor management system that works for any industries not limited to factories, societies, government institutes, and warehouses. A new age contactless way of logging information of visitors, employees, packages, and vehicles. VizMan is a digital logbook so it deters unnecessary use of paper or space since there is no requirement of bundles of registers that is left to collect dust in a corner of a room. Visitor’s essential details, helps in scheduling meetings for visitors and employees, and assists in supervising the attendance of the employees. With VizMan, visitors don’t need to wait for hours in long queues. VizMan handles visitors with the value they deserve because we know time is important to you.
Feasible Features
One Subscription, Four Modules – Admin, Employee, Receptionist, and Gatekeeper ensures confidentiality and prevents data from being manipulated
User Friendly – can be easily used on Android, iOS, and Web Interface
Multiple Accessibility – Log in through any device from any place at any time
One app for all industries – a Visitor Management System that works for any organisation.
Stress-free Sign-up
Visitor is registered and checked-in by the Receptionist
Host gets a notification, where they opt to Approve the meeting
Host notifies the Receptionist of the end of the meeting
Visitor is checked-out by the Receptionist
Host enters notes and remarks of the meeting
Customizable Components
Scheduling Meetings – Host can invite visitors for meetings and also approve, reject and reschedule meetings
Single/Bulk invites – Invitations can be sent individually to a visitor or collectively to many visitors
VIP Visitors – Additional security of data for VIP visitors to avoid misuse of information
Courier Management – Keeps a check on deliveries like commodities being delivered in and out of establishments
Alerts & Notifications – Get notified on SMS, email, and application
Parking Management – Manage availability of parking space
Individual log-in – Every user has their own log-in id
Visitor/Meeting Analytics – Evaluate notes and remarks of the meeting stored in the system
Visitor Management System is a secure and user friendly database manager that records, filters, tracks the visitors to your organization.
"Secure Your Premises with VizMan (VMS) – Get It Now"
2. What is a class ?
A class is logical grouping of attributes(variables)
and methods(functions)
Syntax:
class ClassName:
# class body
Example:
class Student:
# class body
What is an object ?
Object is an instance of a class that has access to all the
attributes and methods of that class.
Syntax:
objectName = ClassName()
Example:
student = Student() # object instantiation
# The object student now has access to all the attributes
and methods of the class Student.
What is object instantiation ?
The process of creation of an object of a class is called instantiation
CLASSES AND OBJECTS
4. ATTRIBUTES AND METHODS
What is the self parameter ?
Every instance method accepts has a default parameter
that is being accepted. By convention, this parameter is
named self.
The self parameter is used to refer to the attributes of
that instance of the class.
Example:
class Student:
def setName(self, name):
self.name = name
student = Student()
student.setName(‘Santosh’)
# The above statement is inferred as
student.setName(‘Santosh’) where the object employee
is taken as the self argument.
What is an init method ?
An init method is the constructor of a class that can
be used to initialize data members of that class.
It is the first method that is being called on creation
of an object.
Syntax:
def __init__(self):
# Initialize the data members of the class
Example:
class Employee:
def __init__(self):
print("Welcome!")
employee = Employee()
# This would print Welcome! since __init__ method
was called on object instantiation
5. What is a class attribute ?
An attribute that is common across all instances of a class is called a class attribute.
Class attributes are accessed by using class name as the prefix.
Syntax:
class className:
classAttribute = value
Example:
class Student:
# This attribute is common across all instances of this class
numberOfStudents = 0
studentOne = Student ()
Student.numberOf Students += 1
print(studentOne.numberOfStudents)
What are data members ?
Data members are attributes declared within a class. They are properties that further define a
class.
There are two types of attributes:
1. Class attributes
2. Instance attributes.
6. What is an instance attribute ?
An attribute that is specific to each instance of a class is called an instance attribute.
Instance attributes are accessed within an instance method by making use of the self object.
Syntax:
class className:
def methodName(self):
self.instanceAttribute = value
Example:
class Student:
def studentDetails(self, name): # name is the instance attribute
self.name = name
7. What is an instance method ?
A method which can access the instance attributes of a class by making use of self object is
called an instance method.
Syntax:
def methodName(self):
# method body
Example:
class Employee:
# employeeDetails() is the instance method
def employeeDetails(self, name):
self.name = name
What are methods ?
A function within a class that performs a specific action is called a method belonging to that
class.
Methods are of two types:
1. Static method
2. Instance method
8. What is a static method ?
A method that does not have access to any of the instance attributes of a class is called a static method.
Static method uses a decorator @staticmethod to indicate this method will not be taking the default self
parameter.
Syntax:
@staticmethod
def methodName(): # Observe that self is not being declared since this is a static method
# method body
Example:
class Student :
numberOfStudents = 0
@StaticMethod # static method that updates the class attribute of the class Student.
def updateNumberOfStudents():
Student.numberOf Students += 1
studentOne = Student()
studentTwo = Student()
studentOne.updateNumberOfStudents()
studentTwo.updateNumberOfStudents()
print(Student.numberOfStudents)
9. What are the ways to access the attributes and methods of a class ?
Attributes and methods of a class can be accessed by creating an object and accessing the attributes
and objects using class name or object name depending upon the type of attribute followed by the dot
operator (.) and the attribute name or method name.
Example:
class Employee:
numberOfStudents = 0
def printNumberOfStudents (self):
print(Student.numberOfStudents)
student = Student()
Student.numberOf Students += 1 # Modify class attribute using dot operator
student.printNumberOfStudents() # Call the instance method using dot operator
11. ABSTRACTION AND ENCAPSULATION
What is encapsulation ?
Hiding the implementation details from the end user is called as
encapsulation.
Example:
Inner Implementation detail of a Mobile phone, how keypad
button and display screen are connect with each other using circuits.
What is abstraction ?
Abstraction is the process of steps followed to achieve
encapsulation.
Example:
Outer Look of a Mobile Phone, like it has a display screen and
Keypad buttons to dial a number.
13. INHERITANCE
What is inheritance ?
Inheriting the attributes and methods of a base class into a derived class is called Inheritance.
Syntax:
class BaseClass:
# Body of BaseClass
class DerivedClass(BaseClass):
# Body of DerivedClass
Example:
class Shape:
unitOfMeasurement = 'centimetre’
class Square(Shape):
def __init__(self):
print("Unit of measurement for this square: ", self.unitOfMeasurement)
# The attribute unitOfMeasurement has been inherited from the class Shape to this class
Square
square = Square()
Parent Class
Derived Class
14. What is multiple inheritance ?
Mechanism in which a derived class inherits from two or more base classes is called a multiple inheritance.
Syntax:
class baseClassOne:
# Body of baseClassOne
class baseClassTwo:
# Body of baseClassTwo
class derivedClass(baseClassOne, baseClassTwo):
# Body of derived class
Example:
class OperatingSystem:
multiTasking = True
class Apple:
website = 'www.apple.com’
class MacOS(OperatingSystem, Apple):
def __init__(self):
if self.multiTasking is True:
print(“{}”.format(self.website))
mac = MacOS()
# class MacOS has inherited 'multitasking' attribute
from the class OperatingSystem and 'website'
attribute from the class 'Apple'
Parent Class
1
Parent Class
2
Derived Class
15. What is multilevel inheritance ?
Mechanism in which a derived class inherits from a base class which has been derived from another base
class is called a multilevel inheritance.
Syntax:
class BaseClass:
# Body of baseClass class
DerivedClassOne(BaseClass):
# Body of DerivedClassOne class
DerivedClassTwo(DerivedClassOne):
# Body of DerivedClassTwo
Example:
class Apple:
website = 'www.apple.com’
class MacBook(Apple):
deviceType = 'notebook computer’
class MacBookPro(MacBook):
def __init__(self):
print("This is a {}. Visit {} for more
details".format(self.deviceType,
self.website))
macBook = MacBookPro()
# MacBookPro class inherits deviceType from the base class
MacBook. It also inherits website from base class of MacBook,
which is Apple
Parent Class
Child Class
Grand Child Class
16. What are the naming conventions used for private, protected and public members ?
Private -> __memberName
Protected -> _memberName
Public -> memberName
How is name mangling done for private members by Python ?
Name mangling is done by prepending the member name with an underscore
and class name.
_className__memberName
17. What is an abstract base class ?
A base class which contains abstract methods that are to be overridden in its derived class is called an
abstract base class.
They belong to the abc module.
Example:
from abc import ABCMeta, abstractmethod
class Shape(metaclass = ABCMeta):
@abstractmethod
def area(self):
return 0
class Square(Shape):
def area(self, side)
return side * side
19. POLYMORPHISM
What is polymorphism ?
The same interface existing in different forms is called polymorphism.
Example :
An addition between two integers 2 + 2 return 4 whereas an addition between two
strings "Hello" + "World" concatenates it to "Hello World"
Why is super() method used ?
super() is used to access the methods of base class.
Example:
class BaseClass:
def baseClassMethod():
print("This is BaseClassOne")
class DerivedClass(BaseClass):
def __init__(self):
super().baseClassMethod() # calls the base class method
20. What is operator overloading ?
Redefining how an operator operates its operands is called operator overloading.
Syntax:
def __operatorFunction__(operandOne, operandTwo):
# Define the operation that has to be performed
Example:
class Square:
def __init__(self, side):
self.side = side
def __add__(sideOne, sideTwo):
return(sideOne.side + sideTwo.side)
squareOne = Square(10)
squareTwo = Square(20)
print("Sum of sides of two squares = ", squareOne + squareTwo)
# After overloading __add__ method, squareOne + squareTwo is interpreted as
Square.__add__(squareOne, squareTwo)
21. What is overriding ?
Modifying the inherited behavior of methods of a base class in a derived class is called overriding.
Syntax:
class BaseClass:
def methodOne(self):
# Body of method
class DerivedClass(baseClass):
def methodOne(self):
# Redefine the body of methodOne
Example:
class Shape:
def area():
return 0
class Square(Shape):
def area(self, side):
return (side * side)