SlideShare a Scribd company logo
BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only.
OBJECT ORIENTED PROGRAMMING
WITH PYTHON
BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only.
LET’S DISCUSS
 Why OOPs
 Classes & Objects
 Inheritance
 Revisiting Types & Exceptions
 Polymorphism
 Operator Overloading
 Method Overriding
 Quick Quiz
BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only.
THE CURRENT SCENARIO
Let’s store employee data
Why OOPs
# Ask for the name of the employee
name = input("Enter the name of the employee: ")
# Ask for the age of the employee
age = input("Enter the age of the employee: ")
# Print the collected information
print(f"Employee Name: {name}")
print(f"Employee Age: {age}")
BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only.
LET’S IMPROVE IT
# Function to input employee data (name and age)
def input_employee_data():
name = input("Enter the name of the employee: ")
age = input("Enter the age of the employee: ")
return name, age
# Function to print employee information
def print_employee_info(name, age):
print(f"Employee Name: {name}")
print(f"Employee Age: {age}")
name, age = input_employee_data()
print_employee_info(name, age)
# Ask for the name of the employee
name = input("Enter the name of the employee: ")
# Ask for the age of the employee
age = input("Enter the age of the employee: ")
# Print the collected information
print(f"Employee Name: {name}")
print(f"Employee Age: {age}")
Why OOPs
BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only.
IS THAT GOOD ENOUGH?
# Function to input employee data (name and age)
def input_employee_data():
name = input("Enter the name of the employee: ")
age = input("Enter the age of the employee: ")
return name, age
# Function to print employee information
def print_employee_info(name, age):
print(f"Employee Name: {name}")
print(f"Employee Age: {age}")
name, age = input_employee_data()
print_employee_info(name, age)
Why OOPs
class Employee:
def input_employee_data(self):
self.name = input("Enter the name of the employee: ")
self.age = input("Enter the age of the employee: ")
def print_employee_info(self):
print(f"Employee Name: {self.name}")
print(f"Employee Age: {self.age}")
# Create an instance of the Employee class
employee = Employee()
# Input employee data using the class method
employee.input_employee_data()
# Print employee information using the class method
employee.print_employee_info()
BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only.
PARADIGMS OF PROGRAMMING
# Ask for the name of the employee
name = input("Enter the name : ")
# Ask for the age of the employee
age = input("Enter the age of the employee: ")
# Print the collected information
print(f"Employee Name: {name}")
print(f"Employee Age: {age}")
# Function to input employee data (name and age)
def input_employee_data():
name = input("Enter the name of the employee: ")
age = input("Enter the age of the employee: ")
return name, age
# Function to print employee information
def print_employee_info(name, age):
print(f"Employee Name: {name}")
print(f"Employee Age: {age}")
name, age = input_employee_data()
print_employee_info(name, age)
class Employee:
def input_employee_data(self):
self.name = input("Enter the name of the employee: ")
self.age = input("Enter the age of the employee: ")
def print_employee_info(self):
print(f"Employee Name: {self.name}")
print(f"Employee Age: {self.age}")
# Create an instance of the Employee class
employee = Employee()
# Input employee data using the class method
employee.input_employee_data()
# Print employee information using the class method
employee.print_employee_info()
Procedural Functional Object Oriented
BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only.
CLASSES
Classes are used to create our
own type of data and give them
names.
Classes are “Blueprints”
BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only.
OBJECTS
Any time you
create a class and
you utilize that
“blueprint” to
create “object”.
BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only.
CLASSES AND OBJECTS IN ACTION
BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only.
CLASSES AND OBJECTS IN ACTION
class Employee:
def input_employee_data(self):
self.name = input("Enter the name of the employee: ")
self.age = input("Enter the age of the employee: ")
def print_employee_info(self):
print(f"Employee Name: {self.name}")
print(f"Employee Age: {self.age}")
# Create an instance of the Employee class
employee1 = Employee()
# Create another instance of the Employee
class
employee2 = Employee()
# Yet another instance of the Employee class
employee3 = Employee()
BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only.
ANATOMY OF A CLASS
class Employee:
...
Class is a
Blueprint
BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only.
METHODS IN CLASS
# Create an instance of the Employee class
employee = Employee()
# Input employee data using the class method
employee.input_employee_data()
class Employee:
def input_employee_data(self):
self.name = input("Enter the name of the employee: ")
self.age = input("Enter the age of the employee: ")
BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only.
WHAT IS “self”
class Employee:
def input_employee_data(self):
self.name = input("Enter the name of the employee: ")
self.age = input("Enter the age of the employee: ")
self refers to the current object that was just created.
BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only.
ATTRIBUTES
class Employee:
def input_employee_data(self):
self.name = input("Enter the name of the employee: ")
self.age = input("Enter the age of the employee: ")
BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only.
SET ATTRIBUTES WHILE CREATING THE OBJECT
class Employee:
def input_employee_data(self):
self.name = input("Enter the name of the employee: ")
self.age = input("Enter the age of the employee: ")
# Driver Code
# Create an instance of the Employee class
employee = Employee()
# Input employee data using the class method
employee.input_employee_data()
class Employee:
def __init__(self, name, age):
self.name = name
self.age = age
# Driver Code
name = input("Enter the name of the employee: ")
age = input("Enter the age of the employee: ")
# Create an instance of the Employee class
employee = Employee(name, age)
# Print the employee data
print("Employee Name:", employee.name)
print("Employee Age:", employee.age)
BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only.
LET’S VISUALISE __init__()
class Employee:
def __init__(self, name, age):
self.name = name
self.age = age
self.name
self.age
name
age
# Create an instance
employee = Employee(name, age)
BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only.
WHERE ARE THESE EMPLOYEE WORKING?
class Employee:
org = 'CompanyName'
def input_employee_data(self):
self.name = input("Enter the name of the employee: ")
self.age = input("Enter the age of the employee: ")
def print_employee_info(self):
print(f"Employee Name: {self.name}")
print(f"Employee Age: {self.age}")
emp = Employee()
print(emp.org)
Class Variables
BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only.
WHAT ABOUT CODE REUSABILITY?
BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only.
INHERITENCE
class Human:
...
class Employee:
...
class Human:
...
class Employee(Human):
...
Inheritance enables us
to create a class that
“inherits” methods,
variables, and attributes
from another class.
BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only.
INHERITENCE IN ACTION
class Human:
def __init__(self, height):
self.height = height
class Employee(Human):
def __init__(self, height, name, age):
super().__init__(height)
self.name = name
self.age = age
BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only.
YOU ARE ALREADY USING CLASSES
https://docs.python.org/3/library/stdtypes.html#str
surprise
BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only.
EXCEPTIONS
BaseException
+-- KeyboardInterrupt
+-- Exception
+-- ArithmeticError
| +-- ZeroDivisionError
+-- AssertionError
+-- AttributeError
+-- EOFError
+-- ImportError
| +-- ModuleNotFoundError
+-- LookupError
| +-- KeyError
+-- NameError
+-- SyntaxError
| +-- IndentationError
+-- ValueError
...
BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only.
POLYMORPHISM
 Poly – many
 Morph - shapes
BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only.
OPERATOR OVERLOADING
 Some operators such as
+ and - can be
“overloaded” such that
they can have more
abilities beyond simple
arithmetic.
class MyNumber:
def __init__(self, num=0):
self.num = num
def __add__(self, other):
return self.num * other.num
BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only.
HOW IT WORKED?
 We override the __add__ method
 https://docs.python.org/3/reference/datamod
el.html?highlight=__add__#object.__add__
BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only.
METHOD OVERRIDING
class Human:
def __init__(self, name, age):
self.name = name
self.age = age
def introduce(self):
print(f"Hello, I am {self.name} and I am {self.age} years old.")
class Employee(Human):
def __init__(self, name, age, employee_id):
super().__init__(name, age)
self.employee_id = employee_id
# Method overriding
def introduce(self):
print(f"Hello, I am {self.name}, an employee with ID {self.employee_id}.")
BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only.
QUIZ TIME
BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only.
THANKS

More Related Content

PDF
ACP Java Assignment.pdf
PDF
Philipp Von Weitershausen Untested Code Is Broken Code
PDF
computer science investigatory project .pdf
PPTX
Programming Primer EncapsulationVB
PPTX
Database system examples.pptx
ODP
Pruebas unitarias con django
PDF
Data centric Metaprogramming by Vlad Ulreche
PDF
Data Centric Metaprocessing by Vlad Ulreche
ACP Java Assignment.pdf
Philipp Von Weitershausen Untested Code Is Broken Code
computer science investigatory project .pdf
Programming Primer EncapsulationVB
Database system examples.pptx
Pruebas unitarias con django
Data centric Metaprogramming by Vlad Ulreche
Data Centric Metaprocessing by Vlad Ulreche

Similar to Object Oriented Programming in Python (20)

PDF
Having issues with passing my values through different functions aft.pdf
PPTX
Final Presentation V1.8
PPTX
HOW TO CREATE A MODULE IN ODOO
PPT
structure and union
PPTX
Programming Primer Encapsulation CS
PPT
Structure and union
PPTX
Oop concept in c++ by MUhammed Thanveer Melayi
DOCX
CIS 247C iLab 4 of 7: Composition and Class Interfaces
PDF
python.pdf
DOCX
2. Create a Java class called EmployeeMain within the same project Pr.docx
PDF
I am trying to change this code from STRUCTS to CLASSES, the members.pdf
DOCX
Written by Dr. Preiser 1 CIS 3100 MS Access Assignment .docx
PPTX
Creation or Update of a Mandatory Field is Not Set in Odoo 17
PPTX
Sencha Touch - Introduction
PPT
Form demoinplaywithmysql
PPTX
How to Show Sample Data in Tree and Kanban View in Odoo 17
KEY
Django Admin: Widgetry & Witchery
PPTX
Presentation_4516_Content_Document_20250204010703PM.pptx
PDF
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYA
PPT
pointer, structure ,union and intro to file handling
Having issues with passing my values through different functions aft.pdf
Final Presentation V1.8
HOW TO CREATE A MODULE IN ODOO
structure and union
Programming Primer Encapsulation CS
Structure and union
Oop concept in c++ by MUhammed Thanveer Melayi
CIS 247C iLab 4 of 7: Composition and Class Interfaces
python.pdf
2. Create a Java class called EmployeeMain within the same project Pr.docx
I am trying to change this code from STRUCTS to CLASSES, the members.pdf
Written by Dr. Preiser 1 CIS 3100 MS Access Assignment .docx
Creation or Update of a Mandatory Field is Not Set in Odoo 17
Sencha Touch - Introduction
Form demoinplaywithmysql
How to Show Sample Data in Tree and Kanban View in Odoo 17
Django Admin: Widgetry & Witchery
Presentation_4516_Content_Document_20250204010703PM.pptx
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYA
pointer, structure ,union and intro to file handling
Ad

Recently uploaded (20)

PDF
Become an Agentblazer Champion Challenge
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PPTX
What to Capture When It Breaks: 16 Artifacts That Reveal Root Causes
PPTX
Materi-Enum-and-Record-Data-Type (1).pptx
PPTX
Save Business Costs with CRM Software for Insurance Agents
PPTX
CRUISE TICKETING SYSTEM | CRUISE RESERVATION SOFTWARE
PDF
Convert Thunderbird to Outlook into bulk
PDF
Community & News Update Q2 Meet Up 2025
PDF
Forouzan Book Information Security Chaper - 1
PDF
How to Choose the Most Effective Social Media Agency in Bangalore.pdf
PPTX
Presentation of Computer CLASS 2 .pptx
PDF
Multi-factor Authentication (MFA) requirement for Microsoft 365 Admin Center_...
PDF
How to Confidently Manage Project Budgets
PDF
Teaching Reproducibility and Embracing Variability: From Floating-Point Exper...
PDF
AI in Product Development-omnex systems
PDF
IEEE-CS Tech Predictions, SWEBOK and Quantum Software: Towards Q-SWEBOK
PDF
Comprehensive Salesforce Implementation Services.pdf
PDF
A REACT POMODORO TIMER WEB APPLICATION.pdf
PPTX
Hire Expert Blazor Developers | Scalable Solutions by OnestopDA
PPTX
Hire Expert WordPress Developers from Brainwings Infotech
Become an Agentblazer Champion Challenge
2025 Textile ERP Trends: SAP, Odoo & Oracle
What to Capture When It Breaks: 16 Artifacts That Reveal Root Causes
Materi-Enum-and-Record-Data-Type (1).pptx
Save Business Costs with CRM Software for Insurance Agents
CRUISE TICKETING SYSTEM | CRUISE RESERVATION SOFTWARE
Convert Thunderbird to Outlook into bulk
Community & News Update Q2 Meet Up 2025
Forouzan Book Information Security Chaper - 1
How to Choose the Most Effective Social Media Agency in Bangalore.pdf
Presentation of Computer CLASS 2 .pptx
Multi-factor Authentication (MFA) requirement for Microsoft 365 Admin Center_...
How to Confidently Manage Project Budgets
Teaching Reproducibility and Embracing Variability: From Floating-Point Exper...
AI in Product Development-omnex systems
IEEE-CS Tech Predictions, SWEBOK and Quantum Software: Towards Q-SWEBOK
Comprehensive Salesforce Implementation Services.pdf
A REACT POMODORO TIMER WEB APPLICATION.pdf
Hire Expert Blazor Developers | Scalable Solutions by OnestopDA
Hire Expert WordPress Developers from Brainwings Infotech
Ad

Object Oriented Programming in Python

  • 1. BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only. OBJECT ORIENTED PROGRAMMING WITH PYTHON
  • 2. BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only. LET’S DISCUSS  Why OOPs  Classes & Objects  Inheritance  Revisiting Types & Exceptions  Polymorphism  Operator Overloading  Method Overriding  Quick Quiz
  • 3. BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only. THE CURRENT SCENARIO Let’s store employee data Why OOPs # Ask for the name of the employee name = input("Enter the name of the employee: ") # Ask for the age of the employee age = input("Enter the age of the employee: ") # Print the collected information print(f"Employee Name: {name}") print(f"Employee Age: {age}")
  • 4. BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only. LET’S IMPROVE IT # Function to input employee data (name and age) def input_employee_data(): name = input("Enter the name of the employee: ") age = input("Enter the age of the employee: ") return name, age # Function to print employee information def print_employee_info(name, age): print(f"Employee Name: {name}") print(f"Employee Age: {age}") name, age = input_employee_data() print_employee_info(name, age) # Ask for the name of the employee name = input("Enter the name of the employee: ") # Ask for the age of the employee age = input("Enter the age of the employee: ") # Print the collected information print(f"Employee Name: {name}") print(f"Employee Age: {age}") Why OOPs
  • 5. BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only. IS THAT GOOD ENOUGH? # Function to input employee data (name and age) def input_employee_data(): name = input("Enter the name of the employee: ") age = input("Enter the age of the employee: ") return name, age # Function to print employee information def print_employee_info(name, age): print(f"Employee Name: {name}") print(f"Employee Age: {age}") name, age = input_employee_data() print_employee_info(name, age) Why OOPs class Employee: def input_employee_data(self): self.name = input("Enter the name of the employee: ") self.age = input("Enter the age of the employee: ") def print_employee_info(self): print(f"Employee Name: {self.name}") print(f"Employee Age: {self.age}") # Create an instance of the Employee class employee = Employee() # Input employee data using the class method employee.input_employee_data() # Print employee information using the class method employee.print_employee_info()
  • 6. BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only. PARADIGMS OF PROGRAMMING # Ask for the name of the employee name = input("Enter the name : ") # Ask for the age of the employee age = input("Enter the age of the employee: ") # Print the collected information print(f"Employee Name: {name}") print(f"Employee Age: {age}") # Function to input employee data (name and age) def input_employee_data(): name = input("Enter the name of the employee: ") age = input("Enter the age of the employee: ") return name, age # Function to print employee information def print_employee_info(name, age): print(f"Employee Name: {name}") print(f"Employee Age: {age}") name, age = input_employee_data() print_employee_info(name, age) class Employee: def input_employee_data(self): self.name = input("Enter the name of the employee: ") self.age = input("Enter the age of the employee: ") def print_employee_info(self): print(f"Employee Name: {self.name}") print(f"Employee Age: {self.age}") # Create an instance of the Employee class employee = Employee() # Input employee data using the class method employee.input_employee_data() # Print employee information using the class method employee.print_employee_info() Procedural Functional Object Oriented
  • 7. BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only. CLASSES Classes are used to create our own type of data and give them names. Classes are “Blueprints”
  • 8. BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only. OBJECTS Any time you create a class and you utilize that “blueprint” to create “object”.
  • 9. BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only. CLASSES AND OBJECTS IN ACTION
  • 10. BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only. CLASSES AND OBJECTS IN ACTION class Employee: def input_employee_data(self): self.name = input("Enter the name of the employee: ") self.age = input("Enter the age of the employee: ") def print_employee_info(self): print(f"Employee Name: {self.name}") print(f"Employee Age: {self.age}") # Create an instance of the Employee class employee1 = Employee() # Create another instance of the Employee class employee2 = Employee() # Yet another instance of the Employee class employee3 = Employee()
  • 11. BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only. ANATOMY OF A CLASS class Employee: ... Class is a Blueprint
  • 12. BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only. METHODS IN CLASS # Create an instance of the Employee class employee = Employee() # Input employee data using the class method employee.input_employee_data() class Employee: def input_employee_data(self): self.name = input("Enter the name of the employee: ") self.age = input("Enter the age of the employee: ")
  • 13. BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only. WHAT IS “self” class Employee: def input_employee_data(self): self.name = input("Enter the name of the employee: ") self.age = input("Enter the age of the employee: ") self refers to the current object that was just created.
  • 14. BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only. ATTRIBUTES class Employee: def input_employee_data(self): self.name = input("Enter the name of the employee: ") self.age = input("Enter the age of the employee: ")
  • 15. BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only. SET ATTRIBUTES WHILE CREATING THE OBJECT class Employee: def input_employee_data(self): self.name = input("Enter the name of the employee: ") self.age = input("Enter the age of the employee: ") # Driver Code # Create an instance of the Employee class employee = Employee() # Input employee data using the class method employee.input_employee_data() class Employee: def __init__(self, name, age): self.name = name self.age = age # Driver Code name = input("Enter the name of the employee: ") age = input("Enter the age of the employee: ") # Create an instance of the Employee class employee = Employee(name, age) # Print the employee data print("Employee Name:", employee.name) print("Employee Age:", employee.age)
  • 16. BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only. LET’S VISUALISE __init__() class Employee: def __init__(self, name, age): self.name = name self.age = age self.name self.age name age # Create an instance employee = Employee(name, age)
  • 17. BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only. WHERE ARE THESE EMPLOYEE WORKING? class Employee: org = 'CompanyName' def input_employee_data(self): self.name = input("Enter the name of the employee: ") self.age = input("Enter the age of the employee: ") def print_employee_info(self): print(f"Employee Name: {self.name}") print(f"Employee Age: {self.age}") emp = Employee() print(emp.org) Class Variables
  • 18. BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only. WHAT ABOUT CODE REUSABILITY?
  • 19. BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only. INHERITENCE class Human: ... class Employee: ... class Human: ... class Employee(Human): ... Inheritance enables us to create a class that “inherits” methods, variables, and attributes from another class.
  • 20. BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only. INHERITENCE IN ACTION class Human: def __init__(self, height): self.height = height class Employee(Human): def __init__(self, height, name, age): super().__init__(height) self.name = name self.age = age
  • 21. BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only. YOU ARE ALREADY USING CLASSES https://docs.python.org/3/library/stdtypes.html#str surprise
  • 22. BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only. EXCEPTIONS BaseException +-- KeyboardInterrupt +-- Exception +-- ArithmeticError | +-- ZeroDivisionError +-- AssertionError +-- AttributeError +-- EOFError +-- ImportError | +-- ModuleNotFoundError +-- LookupError | +-- KeyError +-- NameError +-- SyntaxError | +-- IndentationError +-- ValueError ...
  • 23. BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only. POLYMORPHISM  Poly – many  Morph - shapes
  • 24. BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only. OPERATOR OVERLOADING  Some operators such as + and - can be “overloaded” such that they can have more abilities beyond simple arithmetic. class MyNumber: def __init__(self, num=0): self.num = num def __add__(self, other): return self.num * other.num
  • 25. BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only. HOW IT WORKED?  We override the __add__ method  https://docs.python.org/3/reference/datamod el.html?highlight=__add__#object.__add__
  • 26. BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only. METHOD OVERRIDING class Human: def __init__(self, name, age): self.name = name self.age = age def introduce(self): print(f"Hello, I am {self.name} and I am {self.age} years old.") class Employee(Human): def __init__(self, name, age, employee_id): super().__init__(name, age) self.employee_id = employee_id # Method overriding def introduce(self): print(f"Hello, I am {self.name}, an employee with ID {self.employee_id}.")
  • 27. BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only. QUIZ TIME
  • 28. BUSINESS DOCUMENT This document is intended for business use and should be distributed to intended recipients only. THANKS