Practical 15
Practical 15
Sr. Remark if
Name of Resource Broad Specification Quantity
No. any
1 Computer System Intel i3, 4 GB RAM
For All
2 Operating System Windows/Linux 20
Experiments
3 Development Software Python IDE And VS Code
class Dog(Animal):
def sound(self):
print("Dog barks.")
d = Dog()
d.sound() # Output: Dog barks.
1. Create a class Employee with data members: name, department and salary. Create suitable
methods for reading and printing employee information
class Employee:
def __init__(self, name, department, salary):
self.name = name
self.department = department
self.salary = salary
def display(self):
print("Employee Name:", self.name)
print("Department:", self.department)
print("Salary:", self.salary)
2. Python program to read and print students information using two classes using simple
inheritance.
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def display(self):
print("Name:", self.name)
print("Age:", self.age)
class Student(Person):
def __init__(self, name, age, course):
super().__init__(name, age)
self.course = course
def display(self):
super().display()
print("Course:", self.course)