Program Practise Python
Program Practise Python
Case:
A library system needs a book management application.
Problem:
search_book("101")
search_book("104")
display_books()
###################################################
Question:-
Organizing Python Codes Using Functions
Case:
A car rental company needs a system for managing rentals.
Problem:
Create functions for renting a car, returning a car, and displaying available cars.
Use a dictionary to store car availability and rented cars.
Organize the functions into a well-structured program.
# Main Program
def main():
while True:
print("\nCar Rental System Menu")
print("1. Rent a Car")
print("2. Return a Car")
print("3. Display Available Cars")
print("4. Exit")
if choice == "1":
car_type = input("Enter the car type (SUV/Sedan/Hatchback):
").capitalize()
customer_name = input("Enter your name: ")
rent_car(car_type, customer_name)
else:
print("Invalid choice! Please try again.")
main()