0% found this document useful (0 votes)
10 views3 pages

Practical 15

The document provides Python code examples for creating classes and implementing inheritance. It includes a class for Employee with methods to get and display employee information, a simple inheritance example with classes A and B for student information, and a multiple inheritance example with classes A, B, and C that includes student percentage. Each example demonstrates how to read input and display output using class methods.

Uploaded by

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

Practical 15

The document provides Python code examples for creating classes and implementing inheritance. It includes a class for Employee with methods to get and display employee information, a simple inheritance example with classes A and B for student information, and a multiple inheritance example with classes A, B, and C that includes student percentage. Each example demonstrates how to read input and display output using class methods.

Uploaded by

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

PRACTICAL 15

#1. Create a class Employee with data members: name, department and salary. Create
suitable methods for reading and printing employee information.

class Employee:

def get(self):

self.name=input("Enter Employee name: ")

self.dep=input("Enter Department: ")

self.salary=int(input("Enter Salary: "))

def put(self):

print("\nDetails of the Employee:")

print("Name: ",self.name)

print("Department: ",self.dep)

print("Salary: ",self.salary)

obj=Employee()

obj.get()

obj.put()

#2. Python program to read and print students information using two classes using
simple inheritance.

class A:

def get(self):

self.roll=int(input("\nEnter Roll No:"))

self.name=input("Enter Name:")

class B(A):

def show(self):
print("\nRoll No:",self.roll)

print("Name:",self.name)

obj=B()

obj.get()

obj.show()

#3. Write a Python program to implement multiple inheritance

class A:

def get(self):

self.roll=int(input("\nEnter Roll No:"))

self.name=input("Enter Name:")

self.per=int(input("Enter Percentage:"))

class B(A):

def show(self):

print("\nRoll No:",self.roll)

print("Name:",self.name)

class C(B):

def dis(self):

print("Percentage:",self.per)

obj=C()

obj.get()

obj.show()

obj.dis()
OUTPUT :-

You might also like