IHateMyselfx

i'm just pure bad

Aug 20th, 2022
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.77 KB | None | 0 0
  1. def Ticket_order():
  2.     ticket_prices = {
  3.         "Child": 5,
  4.         "Kid":  10,
  5.         "Teen": 15,
  6.         "Adult": 20
  7.     }
  8.     try:
  9.         ticket_numb = int(input("how many ticket would you like to purchase?\n : "))
  10.     except ValueError:
  11.         Ticket_order()
  12.    
  13.     i = 0
  14.     total = []
  15.     while i < ticket_numb:
  16.         ticket_type = str(input("Enter the ticket type: Child, Kid, Teen, Adult\n : ")).capitalize()
  17.         try:
  18.             print(f"{ticket_type} is " + str(ticket_prices[ticket_type])+"$") if ticket_type in ticket_prices else print("None")    
  19.             i += 1
  20.             total.append(ticket_prices[ticket_type])    
  21.  
  22.         except KeyError:
  23.             print(f"Error! {KeyError} ")
  24.             Ticket_order()
  25.        
  26.  
  27.     print(f"Your total is: {sum(total)}$")
  28.     return mains() if input("\nTo go back press any key ") == type(str) or type(int) else print("none")
  29.  
  30. def Movice_selection():
  31.     film_namez = ["FILMAJÁNLATUNK MÁRA: ","filmem","filmuk","filmek","drog"]
  32.     keys = range(5)
  33.    
  34.     Movie_dict = {
  35.  
  36.     }
  37.    
  38.     for i in keys:
  39.         Movie_dict[i] = film_namez[i]
  40.    
  41.    
  42.  
  43.     print(Movie_dict)
  44.     return mains() if input("\nTo go back press any key ") == type(str) or type(int) else print("none")
  45.    
  46.  
  47. def Ticket_prices():
  48.    
  49.     print("\n Child ticket: age 0-12: 5$\n Kid ticket: age 13-15: 10$\n Teen ticket: age 16-20 15$ \n Adult ticket: age 21 - 99 20$")
  50.     return mains() if input("\nTo go back press any key ") == type(str) or type(int) else print("none") # <--- 'else' rész bőven nincs kész
  51.  
  52.  
  53. def mains(): # <--- main szerűség
  54.  
  55.     print("\n Welcome to the Cinema Ticket System !")
  56.     print(" If you want to see todays movie section press: 1 \n If you want to see ticket prices press: 2 \n If you want to purchase tickets press: 3\n If you want to quit press: 4")
  57.    
  58.     try:
  59.         option_n = int(input("Your choice : "))             #   <---- szolgálata: a program ne dobja el-
  60.    
  61.     except ValueError:                                      # magát ha a retardált user faszságot ad meg
  62.         print("Your Choice must be in the given range !\n")
  63.         mains()
  64.  
  65.     if option_n == 1:                                   # <--- eldönti mit is csinál az inputra
  66.         Movice_selection()
  67.    
  68.     elif option_n == 2:
  69.         Ticket_prices()
  70.    
  71.     elif option_n == 3:
  72.         Ticket_order()
  73.  
  74.  
  75.     elif option_n == 4:
  76.         print("Thanks for your time ! ")
  77.         exit()
  78.  
  79.     else:
  80.         if option_n > 4:                                 # <---- out of range second hiba ellenes layer
  81.             print("\nERROR! input was out of range ! \n")
  82.             mains()
  83.  
  84. mains()     # <---- előhívja a main functiont ami a program alapja
  85. #Ticket_order()
  86. #Ticket_prices()
  87.  
Advertisement
Add Comment
Please, Sign In to add comment