Aayush Python Ass
Aayush Python Ass
Question:
Write a Python Program that allows you to input, display, delete and search for a dog in a system.
➢ To enter a Dog data and add it to the Dog data.
➢ To display the Dog data
➢ To delete a Dog's data from system ➢ To search for a Dog in system.
➢ Additional features should include such as to check the validation for all parameters.
Create this program using classes, objects and functions.
Answer:
DOG MANAGEMENT SYSTEM
To create the Dog management system as described, we will use object-oriented programming (OOP) concepts in
Python. Here's a brief explanation of the components we'll use:
• Dog Manager Class: Manages a collection of Dog objects, allowing for operations such as adding, displaying,
deleting, and searching for Dogs. It also includes methods for validating Dog data.
• Display Method (display): In the Dog class, it prints the Dog’s details. This method is called to show information
about a Dog.
Static Methods:
• validate_Dog: This method is static because it does not need to access or modify instance- specific data. It
performs validation checks on Dog data.
Control Flow:
• While Loops: Used to repeatedly prompt the user for choices and perform actions based on the user’s input.
• Conditional Statements (if-else): Determine which actions to take based on user choices or data validation results.
PYTHON PROGRAM
# Main list to store dog data
dogs = []
while True:
Aayush Raj 24MCS10009
print("Dog Management System:")
print("1. Add Dog")
print("2. Display Dogs")
print("3. Delete Dog")
print("4. Search Dog")
print("5. Exit")
choice = input("Choose an option (1-5): ")
if choice == '1':
add_dog()
elif choice == '2':
display_dogs()
elif choice == '3':
delete_dog()
elif choice == '4':
search_dog()
elif choice == '5':
print("Exiting the system.")
break
else:
print("Invalid option. Please choose again.\n")