0% found this document useful (0 votes)
75 views

Python Oop Part1

The document discusses several programming paradigms including functional programming, procedure oriented programming, and object oriented programming. It then focuses on object oriented programming, explaining that it models real world entities as software objects and allows for reusable code. It defines classes and objects, describing classes as blueprints and objects as copies of classes that are real. It also discusses types of variables including class/static variables, instance variables, and local variables. Finally, it briefly introduces inheritance and types of inheritance like single, multiple, multilevel, and hierarchical inheritance.

Uploaded by

testuser
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views

Python Oop Part1

The document discusses several programming paradigms including functional programming, procedure oriented programming, and object oriented programming. It then focuses on object oriented programming, explaining that it models real world entities as software objects and allows for reusable code. It defines classes and objects, describing classes as blueprints and objects as copies of classes that are real. It also discusses types of variables including class/static variables, instance variables, and local variables. Finally, it briefly introduces inheritance and types of inheritance like single, multiple, multilevel, and hierarchical inheritance.

Uploaded by

testuser
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Programming Paradigms

• Functional programming
• Procedure oriented programming
• Object oriented programming
Object Oriented Programming
• Models real world entities as software objects
• Creating Reusable code

Height Weight age Attributes/Variables

Human
Walk Eat Sleep Behaviour/Methods
Classes and Objects

• Class is a Blueprint
• Objects are copy of the class which are real

Object 1:

Class Human Attribute: John, 20


Behaviour: can Speak English, cannot able to sing
Attribute: Name, age
Behaviour: Speak, Sing Object 2:

Attribute: Ram, 25
Behaviour: can Speak French, can able to sing
Types of Variables
• Class/Static Variable --- Class Level
• Instance Variable --- Object Level
• Local Variable --- Method level
Sample Interview Question
Choose the correct option with respect to the
type and number of variables.
• A. The class Person has 3 instance variables, 2
local variables and 1 static variable
• B. The class Person has 3 instance variables, 1
local variables and 1 static variable
• C. The class Person has 2 instance variables, 3
local variables and 1 static variable
• D. The class Person has 4 instance variables, 2
local variables and no static variable
Inheritance
• Class that inherits all the methods and properties from another class
• Parent Child Relationship
• Parent Class/Base Class
• Child Class/Derived Class
• Code Reusability
Types of Inheritance
• Single Inheritance
-- a child class inherits only a single parent class.
• Multiple Inheritance
-- a child class inherits from more than one parent class.
• Multilevel Inheritance
-- a child class becomes a parent class for another child class.
• Hierarchical Inheritance
-- involves multiple inheritance from the same base or parent class.
Sample Interview Question
What changes should be done in the
given code so as to get the output as
201?
A. Make the instance variable of Base
class public
B. Add a constructor with statements
super().__init__() in Child class
C. Add statement super().__init__() in
the constructor of GrandChild class
D. Add a constructor in Child class
and initialize num to 201

You might also like