Professional Documents
Culture Documents
PTT - II Program With Answs
PTT - II Program With Answs
def display(self):
print ("Length of Rectangle is: ", self.length)
print ("Breadth of Rectangle is: ", self.breadth)
def area(self):
return (self.length*self.breadth)
def perimeter(self):
return (2*self.length + 2*self.breadth)
Output:
Enter the length of the Rectangle: 10
Enter the breadth of rectangle: 5
19. calculate area of rectangle and area of square using method overloading.
Method Overloading in Python | Method Overloading Examples (besanttechnologies.com)
20. create class EMPLYEE with ID and NAME and display its contents.
class Employee: # Employee class
def __init__(self, name, employee_id):
self.name = name # Initialize the attributes
self.employee_id = employee_id
def get_details(self):
print(f"Name: {self.name}, ID: {self.employee_id}") # Print the details of the employee
Output:
All Employees:
Name: John, ID: 001
Name: Jane, ID: 002