Advertisements
Online Mock Tests
Chapters
1: Review of Phython
2: Concept of Object Oriented Programming
3: Classes in Python
▶ 4: Inheritance
Unit -2 : Advanced Programming with Python
1: Liner List Manipulation
2: Stacks & Queues in list
3: Data File Handling
4: Exception Handling & Generate Functions
Unit -3 : Databases Management Systems and SQL
1: Databases Concepts and SQL
2: Structure Query Language
Unit -4 : Introduction to Boolean Algebra
1: Boolean Algebra
2: Boolean Functions and Reduce Forms
Chapter 3: Application of Boolean Logic
Unit -5 : Communication Technologies
Chapter 1: Networking Concepts Part I
Chapter 2: Networking Concepts Part II
Chapter 3: Networking Protocols
Chapter 4: Mobile Telecommunication Technologies, Network Security and Internet Services
![CBSE solutions for Computer Science with Python [English] Class 12 chapter 4 - Inheritance CBSE solutions for Computer Science with Python [English] Class 12 chapter 4 - Inheritance - Shaalaa.com](/images/computer-science-with-python-english-class-12_6:c0c1e36c6bb846c19fd1bb8caad8e289.jpg)
Advertisements
Solutions for Chapter 4: Inheritance
Below listed, you can find solutions for Chapter 4 of CBSE CBSE for Computer Science with Python [English] Class 12.
CBSE solutions for Computer Science with Python [English] Class 12 4 Inheritance EXERCISE [Pages 77 - 86]
Define the term inheritance.
Give one example for abstract method.
What is single inheritance?
What is multiple inheritance? Explain with an example.
Give one example of multilevel inheritance.
Based on the given diagram, answer the following;

- Write the name of the base class and derived class of state.
- Write the type of inheritance depicted in the diagram.
Based on the above diagram, answer the following;

- Write the name of the base class and derived classes.
- Write the type of inheritance depicted in the above diagram.
Based on the above diagram, answer the following;

- Write the name of the base classes and derived class.
- Name the type of inheritance depicted in the above example.
Explain the significance of super() function.
What are abstract methods?
Explain the concept of overriding methods.
Explain multiple inheritance with the help of an example.
How do we implement abstract method in Python. Support your answer with an example.
Find the output of the following code and write the type of inheritance:
class person(object):
def __init__(self,name,age):
self.name=name
self.age=age
def display1(self):
print "Name :",self.name
print "Age :",self.age
class student(person):
def __init__(self,name,age,rollno,marks):
super(student,self).__init__(name,age)
self.rollno=rollno
self.marks=marks
def display(self):
self.display1()
print " Roll No:",self.rollno
print " Marks :",self.marks
p=student('Mona',20,12,99)
p.display()Find the output of the following code and write the type of inheritance:
class person(object):
def __init__(self,name,age):
self.name=name
self.age=age
def display1(self):
print "Name :",self.name
print "Age :",self.age
class student(person):
def __init__(self,name,age,rollno,marks):
super(student,self).__init__(name,age)
self.rollno=rollno
self.marks=marks
def display(self):
self.display1()
print " Roll No:",self.rollno
print " Marks :",self.marks
class Gstudent(student):
def __init__(self,name,age,rollno,marks,stream):
super(Gstudent,self).__init__(name,age,rollno,marks)
self.stream=stream
def display2(self):
self.display()
print " stream:",self.stream
p=Gstudent('Mona',20,12,99,'computer')
p.display2()Find the output of the following code and write the type of inheritance:
class person(object):
def __init__(self,name,age):
self.name=name
self.age=age
def display1(self):
print "Name :",self.name
print "Age :",self.age
class student(object):
def __init__(self,rollno,marks):
self.rollno=rollno
self.marks=marks
def display(self):
print " Roll No:",self.rollno
print " Marks :",self.marks
class Gstudent(person,student):
def __init__(self,name,age,rollno,marks,stream):
super(Gstudent,self).__init__(self,stream)
person.__init__(self,name,age)
student.__init__(self,rollno,marks)
self.stream=stream
def display2(self):
self.display1() s
elf.display()
print " stream:",self.stream
p=Gstudent('Mona',20,12,99,'computer')
p.display2()Rewrite the following code after removing errors. Underline each correction and write the output after correcting the code:
class First():
def __init__(self):
print "first":
class Second(object):
def __init__(self):
print "second"
class Third(First, Second):
def __init__(self):
First.__init__(self):
Second.__init__(self):
print "that's it"
t=Third()t=Third()Complete the following code:
class employee(object):
def __init__(self,no,name,age):
self.no=no
self.name=_____ #complete the statement
self.age=______ #complete the statement
def printval(self):
print "Number:",self.no
print "Name :",self.name
print "Age :",self.age
class pay(object):
def __init__(self,dept,salary): #complete the definition
__________
__________
def display(self): #complete the definition
____________________ # call printval()
__________________ # print dept
___________________ # print salaryDefine a class furniture in Python with the given specifications:
Instance variables:
→ Type
→ Model
Methods
→ getType() To return instance variable Type
→ getModel()To return instance variable Model
→ show() To print instance variable Type and Model
Define a class sofa:
→ No_of_seats
→ Cost
Methods
→ getSeats() To return instance variable No_of_seats
→ getCost() To return instance variable Cost
→ show() To print instance variable No_of_seats and Cost
This class inherits class furniture
Define a class trainer in Python with the given specifications:
Instance variables:
→ Name
→ T_ID
Methods
→ getName()To print instance variable Name
2 getTID()To print instance variable T_ID
Define a class learner in Python with the given specifications:
Instance variables:
→ L_Name
→ L_ID
Methods
→ getName()To print instance variable L_Name
→ getLID()To print instance variable L_ID
Define a class Institute in Python with the given specifications:
Instance variables:
→ I_Name
→ I_Code
Methods
→ getName()To print instance variable I_Name
→ getICode()To print instance variable I_Code
The class Institute inherits the class Trainer and Learner
Define a class student in Python with the given specifications:
Instance variables:
Roll number, name
Methods:
Getdata()- To input roll number and name
Printdata()- To display roll number and name
Define another class marks, which is derived from student class
Instance variable
Marks in five subjects
Methods:
Inputdata() - To call Getdata() and input 5 subjects marks.
Outdata() - To call printdata() and to display 5 subjects marks.
Implement the above program in python.
Define a class employee in Python with the given specifications:
Instance variables:
Employee number, name
Methods:
Getdata()- To input employee number and name
Printdata()- To display employee number and name
Define another class Teaching, which is derived from employee
Instance variable
Department name
Methods:
Inputdata() - To call Getdata() and input department name.
Outdata() - To call printdata() and to display department name.
Define another class Non_teaching, which is derived from employee
Instance variable
Designation
Methods:
Inputdata() - To call Getdata() and input designation.
Outdata() - To call printdata() and to display designation.
Implement the above program in python.
Define a class employee in Python with the given specifications:
Instance variables:
Employee number, name
Methods:
Getdata()- To input employee number and name
Printdata()- To display employee number and name
Define another class payroll, which is derived from employee
Instance variable
Salary
Methods:
Inputdata() - To call Getdata() and input salary.
Outdata() - To call printdata() and to display salary.
Define another class leave, which is derived from payroll.
Instance variable
No of days
Methods:
acceptdata() - To call Inputdata() and input no of days.
showdata() - To call Outdata() and to display no of days.
Implement the above program in python.
Pay roll information system:
→ Declare the base class 'employee' with employee's number, name, designation, address, phone number.
→ Define and declare the function getdata() and putdata() to get the employee's details and print employee's details.
→ Declare the derived class salary with basic pay, DA, HRA, Gross pay, PF, Income tax and Net pay.
→ Declare and define the function getdata1() to call getdata() and get the basic pay,
→ Define the function calculate() to find the net pay
→ Define the function display() to call putdata() and display salary details .
→ Create the derived class object.
→ Read the number of employees.
→ Call the function getdata1() and calculate() to each employees.
→ Call the display() function.
Railway reservation System
→ Declare the base class Train with train number, name, Starting station, destination, departure time, arrival time, etc.
→ Define and declare the function getdata() and putdata() to get the train details and print the details.
→ Define search() function to search train detail using train number.
→ Declare the derived class passenger with ticket number, PNR name of the passenger, gender, age, address, phone number, etc.
→ Declare and define the function getdata1() to call search() function to get the train details and get the passenger's information.
→ Define the function display() to call putdata() and display passenger's details.
→ Create base class object.
→ Read the number of trains.
→ Create the derived class object.
→ Read the number of passengers.
→ Call the function getdata1() to each passenger
→ Call the display() function.
SKP Hotel offers accommodation, meals facilities.
→ Create a class Accommodation with Room Number, type of room, and rent, etc..
→ Create a class meals services includes: meals code, name, price, etc..
→ Create a class customer with customer number, name, address, etc.
→ Customer class is derived by using Accommodation and meals classes.
Implement the following using multilevel information.

→ Create a student class with student number and name
→ Class graduate is created by using student.
→ Graduate class is created using subject code and subject name.
→ Class Post Graduate is created by using Graduat
→ Post Graduate class is created using master subject code and master subject name
Solutions for 4: Inheritance
![CBSE solutions for Computer Science with Python [English] Class 12 chapter 4 - Inheritance CBSE solutions for Computer Science with Python [English] Class 12 chapter 4 - Inheritance - Shaalaa.com](/images/computer-science-with-python-english-class-12_6:c0c1e36c6bb846c19fd1bb8caad8e289.jpg)
CBSE solutions for Computer Science with Python [English] Class 12 chapter 4 - Inheritance
Shaalaa.com has the CBSE Mathematics Computer Science with Python [English] Class 12 CBSE solutions in a manner that help students grasp basic concepts better and faster. The detailed, step-by-step solutions will help you understand the concepts better and clarify any confusion. CBSE solutions for Mathematics Computer Science with Python [English] Class 12 CBSE 4 (Inheritance) include all questions with answers and detailed explanations. This will clear students' doubts about questions and improve their application skills while preparing for board exams.
Further, we at Shaalaa.com provide such solutions so students can prepare for written exams. CBSE textbook solutions can be a core help for self-study and provide excellent self-help guidance for students.
Concepts covered in Computer Science with Python [English] Class 12 chapter 4 Inheritance are .
Using CBSE Computer Science with Python [English] Class 12 solutions Inheritance exercise by students is an easy way to prepare for the exams, as they involve solutions arranged chapter-wise and also page-wise. The questions involved in CBSE Solutions are essential questions that can be asked in the final exam. Maximum CBSE Computer Science with Python [English] Class 12 students prefer CBSE Textbook Solutions to score more in exams.
Get the free view of Chapter 4, Inheritance Computer Science with Python [English] Class 12 additional questions for Mathematics Computer Science with Python [English] Class 12 CBSE, and you can use Shaalaa.com to keep it handy for your exam preparation.
