Advertisement
bl00dt3ars

07. Cinema Tickets

Oct 23rd, 2020
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. student_tickets = 0
  2. standard_tickets = 0
  3. kids_tickets = 0
  4.  
  5. line = input()
  6. while line != "Finish":
  7.   movie_name = line
  8.   free_spaces = int(input())
  9.   bought_tickets = 0
  10.   ticket_type = input()
  11.   while ticket_type != "End":
  12.     if ticket_type == "student":
  13.       student_tickets += 1
  14.     elif ticket_type == "standard":
  15.       standard_tickets += 1
  16.     else:
  17.       kids_tickets += 1
  18.     bought_tickets += 1
  19.     if bought_tickets == free_spaces:
  20.       break
  21.     ticket_type = input()
  22.  
  23.   movie_percentage = bought_tickets / free_spaces * 100
  24.   print(f"{movie_name} - {movie_percentage:.2f}% full.")
  25.   line = input()
  26.  
  27. total_tickets = student_tickets + standard_tickets + kids_tickets
  28. print(f"Total tickets: {total_tickets}")
  29. print(f"{student_tickets / total_tickets * 100:.2f}% student tickets.")
  30. print(f"{standard_tickets / total_tickets * 100:.2f}% standard tickets.")
  31. print(f"{kids_tickets / total_tickets * 100:.2f}% kids tickets.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement