diff --git a/Constructors : Welcome Message with Student Name.md b/Constructors : Welcome Message with Student Name.md index 9c047787..fbf4e011 100644 --- a/Constructors : Welcome Message with Student Name.md +++ b/Constructors : Welcome Message with Student Name.md @@ -11,9 +11,16 @@ To write a Python program that creates a **Student** class with a **default cons 5. **Execute the Program**: Instantiate the `Student` class and call the `show` method. ## 🧾 Program +``` +class Student: def init(self,name,userid): self.name=name self.userid=userid self.display() +def display(self): print(self.userid) name=input() userid=input() obj = +Student(name,userid) obj.display() +``` -Add code here ## Output +image ## Result +The Python program that creates a Student class with a default constructor,which will +take the name and userid of the person as parameters print the userid of the person. diff --git a/Destructor.md b/Destructor.md index dc5537f6..d1fdcce2 100644 --- a/Destructor.md +++ b/Destructor.md @@ -21,9 +21,20 @@ The program defines a class `Demo` with: - Create an instance of the `Demo` class. - Delete the object using the `del` keyword. ## Program -Add code Here +``` +class Demo: +def __init__(self): +print("Alive") +def __del__(self): +print("The object no longer exists") +obj=Demo() +del obj +``` ## 🧪 Output +image ## Result +This project demonstrates how to implement a destructor in Python using a simple class +is executed sucessfully. diff --git a/Heirarchical_Inheritence.md b/Heirarchical_Inheritence.md index ebd02d90..660fc235 100644 --- a/Heirarchical_Inheritence.md +++ b/Heirarchical_Inheritence.md @@ -31,6 +31,53 @@ To write a Python program that uses **Hierarchical Inheritance** to input and di 5. Display collected information using class methods. ## Program -Add code here +``` +class Details: +def __init__(self, name, age): +self.name = name +self.age = age +def getName(self): +return self.name +def getAge(self): +return self.age +class Employee(Details): +def __init__(self, name, age, employee_id, department): +super().__init__(name, age) +self.employee_id = employee_id +self.department = department +def getEmployeeDetails(self): +print("Employee Information:") +print("Name:", self.getName()) +print("Age:", self.getAge()) +print("Employee ID:", self.employee_id) +print("Department:", self.department) +class Patient(Details): +def __init__(self, name, age, patient_id, disease): +super().__init__(name, age) +self.patient_id = patient_id +self.disease = disease +def getPatientDetails(self): +print("Patient Information:") +print("Name:", self.getName()) +print("Age:", self.getAge()) +print("Patient ID:", self.patient_id) +print("Disease:", self.disease) +emp_name = input() +emp_age = int(input()) +emp_id = input() +emp_dept = input() +employee = Employee(emp_name, emp_age, emp_id, emp_dept) +11/20/25, 6:12 PM Module-5/Heirarchical_Inheritence.md at main · kirupa169/Module-5 +https://github.com/kirupa169/Module-5/blob/main/Heirarchical_Inheritence.md 2/3 +The program is successfully excexuted +pat_name = input() +pat_age = int(input()) +pat_id = input() +pat_disease = input() +patient = Patient(pat_name, pat_age, pat_id, pat_disease) +employee.getEmployeeDetails() +patient.getPatientDetails() +``` ## Sample Output +image diff --git a/Multilevel_Inheritence.md b/Multilevel_Inheritence.md index 70d92b10..437f69e6 100644 --- a/Multilevel_Inheritence.md +++ b/Multilevel_Inheritence.md @@ -26,7 +26,22 @@ To write a Python program that uses multilevel inheritance to get and display a - Print all details using class methods. ## Program -Add code here +``` +class student: +def __init__(self,x,y,z): +self.x=x +self.y=y +self.z=z +class s(student): +def show(self): +print(f"{self.x} {self.y} {self.z}") +x=input() +y=int(input()) +z=int(input()) +obj=s(x,y,z) +obj.show() +``` ## Sample Output +image diff --git a/Multiple Inheritence.md b/Multiple Inheritence.md index 9f6f0020..50643bb7 100644 --- a/Multiple Inheritence.md +++ b/Multiple Inheritence.md @@ -24,6 +24,29 @@ To write a Python program to calculate **Add, Sub & Division** using **Multiple - Display the results of the three operations. ## 💻 Program -Add code here +``` +class Calculation1: +def Summation(self, a, b): +return a + b +class Calculation2: +def multi(self, a, b): +return a * b +class Derived(Calculation1, Calculation2): +def Division(self, a, b): +if b != 0: +return a / b +else: +return "Division by zero is not allowed" +num1 = float(input()) +num2 = float(input()) +obj = Derived() +sum_result = obj.Summation(num1, num2) +mul_result = obj.multi(num1, num2) +div_result = obj.Division(num1, num2) +print(sum_result) +print(mul_result) +print(div_result) +``` ## Output Example +image