Advertisement
PASTEit2005

Rental func

Jul 7th, 2025
256
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.43 KB | None | 0 0
  1. def aurora_archive_menu():
  2.     while True:
  3.         clear_console()
  4.         print("--- Welcome to the Aurora Archive Rental Service ---")
  5.         print(f"\nEvery two weeks Aurora customers will be able to rent specific books selected by the staff. There is a varied range of genres, these include sci-fi, action-adventure, and artist biographies.\n\nThe rental period ranges from 3 days to 21 days. Starting from 1 - 3 days the price for renting is $3.\nAfter 3 days the cost reduces to $0.80 per day with the lowest cost being $0.50 per day after 8 days.")
  6.         print()
  7.         print(f"1. Enter rental period")
  8.         print(f"2. Return to main menu")
  9.         try:
  10.             option = int(input("\nPlease enter a number between (1 - 2): "))
  11.         except ValueError:
  12.             print(f"{RED}Invalid option.{RESET}")
  13.             input("Press Enter to restart...")
  14.             continue
  15.  
  16.         if option == 1:
  17.             input("Press Enter to be brought to the rental section")
  18.             rental_service()
  19.         elif option == 2:
  20.             input("Press Enter to return to the main menu...")
  21.             break
  22.         else:
  23.             print(f"\n{RED}You have chosen an invalid option. Please enter a valid option (1 - 5).{RESET}")
  24.             input("Press Enter to restart...")
  25.             continue
  26.  
  27. def rental_service():
  28.         while True:
  29.             clear_console()
  30.             print("--- This is the rental section ---")
  31.             try:
  32.                 days = int(input("Please enter a number between (1 - 21) where the number corresponds to the days of rental period: "))
  33.                 if days < 21:
  34.                     print(f"\n{RED}The number exceeds the duration of the maximum rental period.{RESET}{GREEN} Please type a number no greater than 21.{RESET}")
  35.                 else:
  36.                     break
  37.             except ValueError:
  38.                     print(f"\n{RED}Invalid option. Please enter a number between (1 - 21 days){RESET}.")
  39.                     input("Press Enter to restart...")
  40.             if days == 21:
  41.                 price = 12.00
  42.             elif days <= 3:
  43.                 price = 3.00
  44.             elif days <= 8:
  45.                 price = 3.00 + (days - 3) * 0.80
  46.             else:
  47.                 price = 3.00 + (8 - 3) * 0.80 + (days - 8) * 0.50
  48.             print(f"The rental price for {days} days is ${price:.2f}")
  49.             input("Press Enter to purchase...")
  50.             return
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement