Advertisement
TISAZE

Sales Tickets KIT

Nov 23rd, 2024
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | Source Code | 0 0
  1. def sell_tickets():
  2.     total_tickets = 500
  3.     ticket_price = 100
  4.  
  5.     while total_tickets > 0:
  6.         try:
  7.             requested_tickets = int(input("Enter the number of tickets: "))
  8.            
  9.             if requested_tickets > total_tickets:
  10.                 print(f"Only {total_tickets} tickets available.")
  11.             else:
  12.                 total_tickets -= requested_tickets
  13.                 total_cost = requested_tickets * ticket_price
  14.                 print(f"{requested_tickets} tickets sold. Total cost: {total_cost} manat.")
  15.            
  16.         except ValueError:
  17.             print("Please enter a valid number.")
  18.  
  19.     print("All tickets are sold.")
  20.  
  21. sell_tickets()
Tags: #KIT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement