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

Advanced Python Notes

Here are the steps to define Employee class with parameterized constructor, instance methods to set and get employee age and display employee information: 1. Define Employee class 2. Define __init__() method as parameterized constructor to initialize empno, ename, esal as instance variables 3. Define setEmpAge() method to set empage instance variable by validating age between 21 to 58 4. Define getEmpAge() method to return empage instance variable 5. Define DisplayEmpInfo() method to print empno, ename, esal, empage 6. Create Employee class object and initialize with constructor 7. Call setEmpAge() method to set age by user input 8. Call
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

Advanced Python Notes

Here are the steps to define Employee class with parameterized constructor, instance methods to set and get employee age and display employee information: 1. Define Employee class 2. Define __init__() method as parameterized constructor to initialize empno, ename, esal as instance variables 3. Define setEmpAge() method to set empage instance variable by validating age between 21 to 58 4. Define getEmpAge() method to return empage instance variable 5. Define DisplayEmpInfo() method to print empno, ename, esal, empage 6. Create Employee class object and initialize with constructor 7. Call setEmpAge() method to set age by user input 8. Call
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 24

OBJECT ORIENTED PROGRAM SYSTEM

-------------------------------
PROGRAMMING APPROACHES ARE TWO TYPES.

1)PROCEDURAL ORIENTED PROGRAMING APPROACH

WHAT IS PROCEDURAL ORIENTED PROGRAMING


THIS IS A COLLECTION OF FUNCTIONS (METHODS OR PROCEDURES)
STRUCTURE
M1()
{

}
M2()
{
}
MAIN()
{
M1()
M2()
}

EX: C

2) WHAT IS OBJECT ORIENTED PROGRAMING APPROACH


IN THIS APPROACH PROGRAM IS A COLLECTION OF CLASSES.
STRUCTURE OF OOPS
CLASS C1
{
M1()
{
}
M2()
{
}
CLASS C2
{
MAIN()
{
C1.M1()
C2.M2()
}}

Eg: C++,JAVA, PYTHON

OOPS PRINCIPLES

EVERY OBJECT ORIENTED PROGRAMING LANGUAGE FOLLOW THE FOLLOWING 4 PRINCIPLES

1) ENCAPSULATION
2) ABSTRACTION
3) INHERITENCE
4) POLYMORPHISM

class <classname>:
states
behaviours

what is state?
state represents some value
state can be variable or constant

what is variable
a state which represent some value but value can be chaged is called as variable

what is constant

what is state? Ans:- state represnts some value.. state can be variable or
constant..
what is variable? ANs: a state which represnt some value but value can be changed
is called as variable..

what is constant? state which represnt some value but value cant be changed is
called as constant..

types of variables
------------------
in python we have 3 types of variables

1) local varibale
2) instance variable
3) static varibale

1)A varibale which is declared within the function or method is called local
variables.
local varibales we can access only within that function.

Q)when memory will allocate for local variable


Ans)As part of method execution.

Q)when memory will deallocate for local varibale


Ans)once method execution completed.

2) Instance variable

when object created instance varibale generate

3)what is static variable..?


Ans: a variable which is declared inside the class or inside the static method by
prefixing class name is called as static variable..

Example to declar static variable

MyClass.a=10 when

static variable will get memrory?


Ans: .at the time of class is loading.
when static variable will destroy?
Ans: at the time of class is unloading..

note:
when we r declaring static variable with in class prefixing class name is
optional..but when r declaring static variable inside the static method prefixing
class name is compulosry..
what is Behvaiour?
Ans: .
->in python we can define 2 types of behaviours.
1)method or function or procedure.. 2)cosntructor..

what is method?
Ans: A behvaiour which represent some functionality, will execute when ever
programmer will call is called as method.

Types of methods
in python we will have 3 types of methods 1)instances method 2)static method
3)class method

what is instance method?


A method which is taking self keyword as first parameter is called as instance
method.
Instance method address will avilable within the object. Due to that reason
instance method we have to access by using object.

note : To define a method or a constructor in Python we should prefix def keyword.

Syntax to define instance method

def<method name(self)>:
<logic>

Types of construcotrs..
-----------------------------
constructors are two types..
1)default constructor or parameter less construcotr.
2)parameterized construcotor
----------------------------------------------
1)what is default constructor or parameter less construcotr.?
------------------------------------
Ans:
while defining a constructor..if we didn't declared any parameter except self
keyword.. which is called as default constructor..
----------------------------------------
<syntax to define default constructor>
---------------------------------------
def __init__(self):
<self.instance variablename>=<value>

Example to define Employee class by intializing empno,empname,empsal by using


defualt contructor..
------------------------------------------------
note:here for employee class
create two object..
one is emp1
two is emp2
---------------------------------------------------
what is parameteized construcotr?
------------------------------------
Ans:

task1
------------
define student class
states are:
----------------
stid
stname
stloc
behvaiours are:
-----------------
->parameterized constructor
->DisplayStudentInfo()
----------------------------
task2:
-------------------
define faculty class
states are:
------------------
fid
fname
fphno
behvaiours are:
------------------
->parameterized construcotr
->DisplayFacultyInfo()

7:54 PM: define Student..class


states.. are:
----------------
stid
stname
sttotmarks of m1,m2,m3
stavgmarks of m1,m2,m3
stresult of m1,m2,m3
------------------------------------------
behvaiours
--------------------
->parameterized consturcotr.
->CalResult(m1,m2,m3)
->Fail
if he got lessthan 35 in any one subject
i.e m1 or m2 or m3
->First class
if avgmarks>=60
->second class
if avgmarks>=50
->Third class
if avgmarks>=35
-
->DisplayStudentInfo()
stid
stname
sttotmarks
stavgmarks..
stResult..
-------------
7:13 PM: when we will go fofr local variable?
Ans:-
when every a field is required only
with in that method or constructor..
we will declare particular field
as local variable..
-------------------------------------------
when we will go for instance variable?\
Ans:
when ever a field is required for every object..
with the different value..
for example in Employee class
-------------------------------
empno
empname
empsal
--------------------------------------------
what is static varible?
Ans:-
a variable which we declared with in the
class or static method..
by prefixing class name..is called
as static varible..
note:-
for static varible when we r declaring
with in static method prefixing class
name is optional..
-------------------------------------

when we will go fofr local variable?


Ans:-
when every a field is required only
with in that method or constructor..
we will declare particular field
as local variable..
-------------------------------------------
when we will go for instance variable?\
Ans:
when ever

RN Reddy IT School (to All - Entire Audience):

7:14 PM: when we will go for instance variable?\


Ans:
when ever a field is required for every object..
with the different value..
for example in Employee class
-------------------------------
empno
empname
empsal
--------------------------------------------
what is static varible?
Ans:-
a variable which we declared with in the
class or static method..
by prefixing class name..is called
as static varible..
note:-
for static varible when we r declaring
with in static method prefixing class
name is optional..
-------------------------------------

Q: two completed sir

RN Reddy IT School (to All - Entire Audience):

7:13 PM: when we will go fofr local variable?


Ans:-
when every a field is required only
with in that method or constructor..
we will declare particular field
as local variable..
-------------------------------------------
when we will go for instance variable?\
Ans:
when ever a field is required for every object..
with the different value..
for example in Employee class
-------------------------------
empno
empname
empsal
--------------------------------------------
what is static varible?
Ans:-
a variable which we declared with in the
class or static method..
by prefixing class name..is called
as static varible..
note:-
for static varible when we r declaring
with in static method prefixing class
name is optional..
-------------------------------------

when we will go for local variable?


Ans:-
when every a field is required only
with in that method or constructor..
we will declare particular field
as local variable..
-------------------------------------------
when we will go for instance variable?\
Ans:
when ever

RN Reddy IT School (to All - Entire Audience):


7:14 PM: when we will go for instance variable?\
Ans:
when ever a field is required for every object..
with the different value..
for example in Employee class
-------------------------------
empno
empname
empsal
--------------------------------------------
what is static varible?
Ans:-
a variable which we declared with in the
class or static method..
by prefixing class name..is called
as static varible..
note:-
for static varible when we r declaring
with in static method prefixing class
name is optional..
-------------------------------------------------------------

RN Reddy IT School (to All - Entire Audience):

7:13 PM: when we will go for instance method\?


Ans:-
->when ever method functionality is depending on
atleast one instance variable..
then we will go for instance method..
---------------end------------------------
when we will go for static method?
Ans:-
->when ever method functionality is
not depening on any instance variable
we will define it as static method..
---------------------------------------

RN Reddy IT School (to All - Entire Audience):

7:18 PM: class MyClass:


compname="Wipro"
def __init__(self,eno,ename,esal):
self.empno=eno
self.empaname=ename
self.empsal=esal
def DisplayEmpInfo(self):
print("EmpNo is:",self.empno)
print("EmpName is:",self.empname)
print("EmpSAL is :",self.empsal)
print("company name is:",MyClass.compname)
def Greetings():
print("good morning")
======================================================

RN Reddy IT School (to All - Entire Audience):


7:23 PM: class Employee:
def __init__(self,eno,ename,esal):
self.empno=eno
self.empname=ename
self.empsal=esal
def setEmpAge(self,eage):
while eage<21 or eage>58:
eage=int(input("pls enter ur age between 21 to 58:"))
self.empage=eage
def getEmpAge(self):
return self.empage
def DisplayEmpInfo(self):
print("Employee No is:",self.empno)
print("Employee Name is:",self.empname)
print("Emplopyee salary is:",self.empsal)
obj=Employee(111,"rama",1000)
obj.DisplayEmpInfo()
myage=int(input("Enter ur age:"))
obj.setEmpAge(myage)
print("Employee age is:",obj.getEmpAge())
---------------------------------------------------------
RN Reddy IT School (to All - Entire Audience):

7:19 PM: what is inheritance?


Ans:-
inheriting the members from one class to another
class is called as inheritence..
->Estblishing parrent and child relation
between the classes is called as inheritence..
->a class which is giving is called as
parent class or super class or
base class
->a class which is reciving is called as
child class or sub class or derived class....
->because of inheritence super class members
can accessed by sub class but not vice verss
<syntax of inheritence>
-------------------------------
class BC:
//members
class DC(BC):
//MEMBERS
Types of inheritence
--------------------------------
in python we have various types of inheritence like below..
-----------------------------------------------------------
1)single inheritence
2)multiple inheritence
3)multi level inheritence
4)multi path inheritence
5)Hierarchal inheritence
6)Hybrid inheritence..
----------------------------------

RN Reddy IT School (to All - Entire Audience):

7:34 PM: Example 2 to impliment single inheritence..


-----------------------------------------------
BC
----------
states
-----------
self.a
self.b
behvaiours
--------------
->parameterized constructor
->DisplayBC(self)
-------------------
DC(BC)
-----------------
states
----------------
self.i
self.j
---------------------
behaviours
----------------
->prameterized constructor
->DisplayDC(self)

RN Reddy IT School (to All - Entire Audience):

7:56 PM: class BC:


def __init__(self,x,y):
self.a=x
self.b=y
def DisplayBc(self):
print("a value is:",self.a)
print("b value is:",self.b)
class DC(BC):
def __init__(self,m,n):
super().__init__(10,20)
self.i=m
self.j=n
def DisplayDc(self):
super().DisplayBc()
print("i value is:",self.i)
print("j value is:",self.j)
obj=DC(100,200)
obj.DisplayDc()
========================================================================

Q: single level inheritance

Q: one dept can contain more than one employee. But one employee may not belong to
more than one department..

RN Reddy IT School (to All - Entire Audience):

7:30 PM: Example to impliment single inheritence..


-------------------------------------------
Department
--------------------
states
--------------------
deptno
deptname
behaviours
-------------------
->parameterized constructor
->DisplauDeptInfo(self)
Employee(Department)
---------------------------
states
--------------
empno
empname
empsal
behaviours
----------------------
->parametrized cosntrucotr
->DisplayEmpInfo(self)..
=======================================================================

class Department:
def __init__(self,dno,dname):
self.deptno=dno
self.deptname=dname
def DisplayDeptInfo(self):
print("Department Number is:",self.deptno)
print("Department name is:",self.deptname)
class Employee(Department):
def __init__(self,eno,ename,esal):
super().__init__(111,'Technical')
self.empno=eno
self.empname=ename
self.empsal=esal
def DisplayEmpInfo(self):
super().DisplayDeptInfo()
print("Employee No is:",self.empno)
print("Employee Name is:",self.empname)
print("Employee Salary is:",self.empsal)
obj=Employee(111,'rama',1000)
obj.DisplayEmpInfo()
class Department:
def __init__(self,dno,dname):
self.deptno=dno
self.deptname=dname
def DisplayDeptInfo(self):
print("Department Number is:",self.deptno)
print("Department name is:",self.deptname)
class Employee(Department):
def __init__(self,eno,ename,esal):
sup

class Department:
def __init__(self,dno,dname):
self.deptno=dno
self.deptname=dname
def DisplayDeptInfo(self):
print("Department Number is:",self.deptno)
print("Department name is:",self.deptname)

8:21 PM: class Employee(Department):


def __init__(self,eno,ename,esal):
super().__init__(111,'Technical')
self.empno=eno
self.empname=ename
self.empsal=esal
def DisplayEmpInfo(self):
super().DisplayDeptInfo()
print("Employee No is:",self.empno)
print("Employee Name is:",self.empname)
print("Employee Salary is:",self.empsal)

obj=Employee(111,'rama',1000)
obj.DisplayEmpInfo()

8:24 PM: hw
task1
--------------
parrent class
Course
CHild class
student
task2:
---------------
parrent class
course
child class
faculty
task3:
------------------
parrent class
Shop
child class
customer

what is self?
Ans:
self is a keyword which represnt current
class object
super is a keyword.which rerepesnt super
class object
super() is using for
parrent class construcotr or instance method..

class BC:
def __init__(self,x,y):
self.a=x
self.b=y
def DisplayBcInfo(self):
print("a value is:",self.a)
print("b value is:",self.b)
class DC(BC):
def __init__(self,m,n):
super().__init__(10,20)
self.i=m
self.j=n
def DisplayDcInfo(self):
super().DisplayBcInfo()
print("i value is:",self.i)
print("j value is:",self.j)
class TC(DC):
def __init__(self,q,r):
super().__init__(100,200)
self.o=q
self.p=r
def DisplayTcInfo(self):
super().DisplayDcInfo()
print("o value is:",self.o)
print("p value is:",self.p)
obj=TC(1000,2000)
obj.DisplayTcInfo()
===================================

class Department:
def __init__(self,dno,dname):
self.dno=dno
self.dname=dname
def DisplayDeptInfo(self):
print("department no is:",self.dno)
print("department name is:",self.dname)
class Branch(Department):
def __init__(self,bid,bname):
super().__init__(10,'HR')
self.branchid=bid
self.branchname=bname
def DisplayBranchInfo(self):
super().DisplayDeptInfo()
print("branch id is:",self.branchid)
print("branch name is:",self.branchname)
class Employee(Branch):
def __init__(self,eno,ename,esal):
super().__init__(123,'Hyd')
self.empno=eno
self.empname=ename
self.empsal=esal
def DisplayEmpInfo(self):
super().DisplayBranchInfo()
print("Employee No is:",self.empno)
print("Employee Name is:",self.empname)
print("Employee salary is:",self.empsal)
obj=Employee(111,'rama',1000)
obj.DisplayEmpInfo()

task1
University class
College class
Student clas
impliment multi level inheritence
task2
------------------------------------
University class
College class
Faculty clas
impliment multi level inheritence

RN Reddy IT School (to All - Entire Audience):

7:45 PM: class BC1:


def __init__(self,x,y):
self.a=x
self.b=y
def DisplayBc1(self):
print("a value is:",self.a)
print("b value is:",self.b)
class BC2:
def __init__(self,m,n):
self.i=m
self.j=n
def DisplayBc2(self):
print("m value is:",self.i)
print("n value is:",self.j)
class DC(BC1,BC2):
def __init__(self,q,r):
BC1.__init__(self,10,20)
BC2.__init__(self,100,200)
self.o=q
self.p=r
def DisplayDc(self):
super().DisplayBc1()
super().DisplayBc2()
print("o value is:",self.o)
print("p value is:",self.p)
obj=DC(1000,2000)
obj.DisplayDc()
RN Reddy IT School (to All - Entire Audience):

7:23 PM: Example to impliment multipath inheritence..


------------------------------------------
BC
states are:
------------
a,b
behvaiours are:
-------------------
->parameterised constructor
->DisplayBc(self)\
-------------------------
DC1(BC)
-------------
STATES ARE:
------------------
i,j
behvaiours are:
---------------------
->parameterised cosntructor
->DisplayDC1(SELF)
----------------------------
DC2(BC)
----------
states are:
----------------
o,p
behvaiours are:
--------------------
->parameterized construcotr
->DisplayDc2(self)
---------------------------
TC(DC1,DC2)
states are:
-----------------------
c,d
behvaours are:
------------------
->parameterized constructor
->DisplayTc(self)
---------------end---------------------------

RN Reddy IT School (to All - Entire Audience):

7:15 PM: class BC:


def __init__(self,x,y):
self.a=x
self.b=y
def DisplayBC(self):
print("a value is:",self.a)
print("b value is:",self.b)
class DC1(BC):
def __init__(self,m,n):
BC.__init__(self,10,20)
self.i=m
self.j=n
def DisplayDC1(self):
super().DisplayBC()
print("i value is:",self.i)
print("j value is:",self.j)
class DC2(BC):
def __init__(self,q,r):
BC.__init__(self,10,20)
self.o=q
self.p=r
def DisplayDC2(self):
super().DisplayBC()
print("o value is:",self.o)
print("p value is:",self.p)
class TC(DC1,DC2):
def __init__(self,e,f):
DC1.__init__(self,100,200)
DC2.__init__(self,1000,2000)
self.c=e
self.d=f
def DisplayTC(self):
super().DisplayDC1()
super().DisplayDC2()
print("c value is:",self.c)
print("d value is:",self.d)
obj=TC(10000,20000)
obj.DisplayTC()

RN Reddy IT School (to All - Entire Audience):

7:25 PM:

5)hierarchial inheritence
-------------------------------
inheriting one base class into multiple
derived classes is called as
hierarchial inheritence
example
--------------------------
class BC:
logic
class DC1(BC):
LOGIC\
class DC2(BC):
LOGIC
class DC3(BC):
LOGIC

RN Reddy IT School (to All - Entire Audience):


7:32 PM: <syntax>
----------------------
class C1:
logic
class C2(C1):
logic
class C3(C2):
logic
class C4(c1,c2,c3)
-

Audience Question

Q: yes sir

A: 1)what is procedurel oriented approach?


2)what is object oriented approach?
3)what r oops pricnciples?
4)what is class?
5)what is state?
6)what is behvaiour?
7)when we will go for state?
8)when we will go for behvaiour?
9)what is local variable?
10)when the memory will allocate and when the
memory will dealocate for local variable?
11)what is instance variable?
12)when the memory will allocate and when the
memory will dealocate for instance varible?
13)what is static variable?
14)when memory will allocate and dealocate for
static variable?
15)what is method?
16)what is constructutr?
17)when we will go for method and constructor?
18)when we will go for local variable
,instance variable ,static variable?
19)when we will go for instance method?
20)when we will go for static method?
21)when is paramter and why parameter?
22)what is self and super?
23)write the features of constructor?
24)what is setter and getter and what is the purpose
of setter and getter?
25)write all the types of inheritence with
syntaxes?

Audience Question

Q: submittes exam sir

A: what is Poymorphism?
------------------------
Ans:
polymorphism means one name many forms..
->implimenting multiple functionalities
with the same name is called as
polymorphsim..
that means implimneting multiple methods.\
with same name and different behvaiour
is called as polymorphsim..

what is Poymorphism?
------------------------
Ans:
polymorphism means one name many forms..
->implimenting multiple functionalities
with the same name is called as
polymorphsim..
that means implimneting multiple methods.\
with same name and different behvaiour
is called as polymorphsim..

Q: yes sir

RN Reddy IT School (to All - Entire Audience):

7:08 PM: what is overloading?


----------------------------
Ans:
implimenting multiple methods..with the
same name but diffrent signature
(number of argument) is called as
overloading..
types of overloading
---------------------------------
in python we can impliment three types of
overloading
1)method overloading
2)operator overloading
3)cosntructor overloading..
-----------------end---------------------------

Audience Question

Q: yes sir

A: what is overloading?
----------------------------
Ans:
implimenting multiple methods..with the
same name but diffrent signature
(number of argument) is called as
overloading..
types of overloading
---------------------------------
in python we can impliment three types of
overloading
1)method overloading
2)operator overloading
3)cosntructor overloading..
-----------------end---------------------------

Audience Question

Q: submitted sir

A: 1what is Poymorphism?
------------------------
2write the Tyepes of polymorphsim?
------------------------------------
3what is overloading?
-------------------
4write the types of overloading
------------------------
5)what is overriding..

Audience Question

Q: yes sir

A: 2)what is overriding..?
Ans:
impliment one method in super class and another
method in sub class with same name and same
\signature is called as overriding..

RN Reddy IT School (to All - Entire Audience):

7:14 PM: 1)what is


method overloading?
Ans:-
if 2 methods are having same name with
different arguments list.. then these methods
are called as overloaded methods..
-------------------------------
Audience Question

Q: one thing many forms

A: class Calculate:
def Add(self,a=None,b=None,c=None):
if a!=None and b!=None and c!=None:
print("sum of three numbers are:",a+b+c)
elif a!=None and b!=None:
print("sum of 2 numbers are:",a+b)
else:
print("Enter 2 or 3 numbers..")
obj=Calculate()
obj.Add(10,20)
obj.Add(10,20,30)

RN Reddy IT School (to All - Entire Audience):

7:19 PM: class Calculate:


def Add(self,a=None,b=None,c=None):
if a!=None and b!=None and c!=None:
print("sum of three numbers are:",a+b+c)
elif a!=None and b!=None:
print("sum of 2 numbers are:",a+b)
else:
print("Enter 2 or 3 numbers..")
obj=Calculate()
obj.Add(10,20)
obj.Add(10,20,30)

Audience Question

Q: HELLO SIR GOOD EVENING

A: 1.what is Poymorphism?
------------------------
polymorphism means one name many forms..
->implimenting multiple functionalities
with the same name is called as
polymorphsim..
that means implimneting multiple methods.\
with same name and different behvaiour
is called as polymorphsim..
Tyepes of polymorphsim
---------------------------
in python polymorphsim are two types..
1)overloading
2)overriding
what is overloading?
----------------------------
Ans:
implimenting multiple methods..with the
same name but diffrent signature
(number of argument) is called as
overloading..
types of overloading
---------------------------------
in python we can impliment three types of
overloading
-------------------------------------------
1)what is
method overloading?
Ans:-
if 2 methods are having same name with
different arguments list.. then these methods
are called as overloaded methods..
----------------------------------------------------
Example 1 for method overloading..
------------------------------------------

RN Reddy IT School (to All - Entire Audience):

6:57 PM: 1.what is Poymorphism?


------------------------
polymorphism means one name many forms..
->implimenting multiple functionalities
with the same name is called as
polymorphsim..
that means implimneting multiple methods.\
with same name and different behvaiour
is called as polymorphsim..
Tyepes of polymorphsim
---------------------------
in python polymorphsim are two types..
1)overloading
2)overriding
what is overloading?
----------------------------
Ans:
implimenting multiple methods..with the
same name but diffrent signature
(number of argument) is called as
overloading..
types of overloading
---------------------------------
in python we can impliment three types of
overloading
-------------------------------------------
1)what is
method overloading?
Ans:-
if 2 methods are having same name with
different arguments list.. then these methods
are called as overloaded methods..
----------------------------------------------------
Example 1 for method overloading..
------------------------------------------

Audience Question

Q: 2 sie

A: class Calculate:
def Add(self,*a):
sum=0
for i in a:
sum=sum+i
print("sum is:",sum)
obj=Calculate()
obj.Add(10,20)
obj.Add(10,20,30)
obj.Add(10,20,30,40)

RN Reddy IT School (to All - Entire Audience):

7:09 PM: class Calculate:


def Add(self,*a):
sum=0
for i in a:
sum=sum+i
print("sum is:",sum)
obj=Calculate()
obj.Add(10,20)
obj.Add(10,20,30)
obj.Add(10,20,30,40)

============================================

Audience Question

Q: clearly understand

A: class Calculate:
def __init__(self,*a):
sum=0
for i in a:
sum=sum+i
print("sum is:",sum)
obj1=Calculate(10,20)
obj2=Calculate(10,20,30)
obj3=Calculate(10,20,30,40)
==================================================================

RN Reddy IT School (to All - Entire Audience):

7:28 PM: class Calculate:


def __init__(self,*a):
sum=0
for i in a:
sum=sum+i
print("sum is:",sum)
obj1=Calculate(10,20)
obj2=Calculate(10,20,30)
obj3=Calculate(10,20,30,40)

Audience Question

Q: 1 constructor

A: 1)what is method overriding?


Ans:
re implimenting super class method with in the
sub class with the same name and same
signature (same number of arguments)is called
as method overriding..

Audience Question

Q: we took sir

A: Exception Handling
----------------------------
what is an excpetion?
Ans:
an excpetion is a run time error..
------------------------------------------
what is an exception handling?
Ans:
Exception handling is a predeifned mechanism
to handle run time errors..
by using try,except,finally blocks..
----------------------------end-----------
pythin is providing various predefined
execeotion classes..to handle
various runtime errors..
for example
------------------
for every error it will provide one
predefined excpetion class
for example
to handle divide by zero error
class name is
ZeroDivisionError
to handle arthametic error
class name is
ArthemericError
like that..
---------------end--------------------------
<syntax of try,except,finally block>
--------------------------------------
Audience Question

Q: we took sir

A: Exception Handling
----------------------------
what is an excpetion?
Ans:
an excpetion is a run time error..
------------------------------------------
what is an exception handling?
Ans:
Exception handling is a predeifned mechanism
to handle run time errors..
by using try,except,finally blocks..
----------------------------end-----------
pythin is providing various predefined
execeotion classes..to handle
various runtime errors..
for example
------------------
for every error it will provide one
predefined excpetion class
for example
to handle divide by zero error
class name is
ZeroDivisionError
to handle arthametic error
class name is
ArthemericError
like that..
---------------end--------------------------
<syntax of try,except,finally block>
--------------------------------------

You might also like