Kaloyankerr

Cinema Tickets

Mar 20th, 2020
1,539
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | None | 0 0
  1. film = input()
  2.  
  3. total_standard = 0
  4. total_students = 0
  5. total_kids = 0
  6.  
  7. while film != "Finish":
  8.     free_space = int(input())
  9.     filled_space = 0
  10.     while filled_space < free_space:
  11.         ticket = input()
  12.  
  13.         if ticket == "standard":
  14.             filled_space += 1
  15.             total_standard += 1
  16.         elif ticket == "student":
  17.             filled_space += 1
  18.             total_students += 1
  19.         elif ticket == "kid":
  20.             filled_space += 1
  21.             total_kids += 1
  22.         elif ticket == "End":
  23.             break
  24.  
  25.     percent_full = filled_space * 100 / free_space
  26.     print(f"{film} - {percent_full:.2f}% full.")
  27.     film = input()
  28.  
  29. total_tickets = total_students + total_standard + total_kids
  30. percent_students = total_students * 100 / total_tickets
  31. percent_standard = total_standard * 100 / total_tickets
  32. percent_kids = total_kids * 100 / total_tickets
  33.  
  34. print(f"Total tickets: {total_tickets}")
  35. print(f"{percent_students:.2f}% student tickets.")
  36. print(f"{percent_standard:.2f}% standard tickets.")
  37. print(f"{percent_kids:.2f}% kids tickets.")
Advertisement
Add Comment
Please, Sign In to add comment