Advertisement
exDotaPro

7_april_2019_6_cinema_tickets

Jan 21st, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.55 KB | None | 0 0
  1. student_tickets = 0
  2. standard_tickets = 0
  3. kids_tickets = 0
  4. current_movie_tickets = 0
  5. total_tickets = 0
  6.  
  7. current_movie = ''
  8.  
  9. command = input()
  10.  
  11. while command != 'Finish':
  12.     movie_name = command
  13.     free_seats = int(input())
  14.  
  15.     for seats in range(1, free_seats + 1):
  16.         ticket_type = input()
  17.  
  18.         if ticket_type == 'student':
  19.             student_tickets += 1
  20.             current_movie_tickets += 1
  21.             total_tickets += 1
  22.         elif ticket_type == 'standard':
  23.             standard_tickets += 1
  24.             current_movie_tickets += 1
  25.             total_tickets += 1
  26.         elif ticket_type == 'kid':
  27.             kids_tickets += 1
  28.             current_movie_tickets += 1
  29.             total_tickets += 1
  30.  
  31.         if ticket_type == 'End' or free_seats == current_movie_tickets:
  32.             seats_taken = (current_movie_tickets / free_seats) * 100
  33.             current_movie = movie_name
  34.             print(f'{current_movie} - {seats_taken:.2f}% full.')
  35.             current_movie_tickets = 0
  36.             break
  37.  
  38.     command = input()
  39.  
  40.     if command == 'Finish':
  41.         average_student_tickets = (student_tickets / total_tickets) * 100
  42.         average_standard_tickets = (standard_tickets / total_tickets) * 100
  43.         average_kids_tickets = (kids_tickets / total_tickets) * 100
  44.  
  45.         print(f'Total tickets: {total_tickets}')
  46.         print(f'{average_student_tickets:.2f}% student tickets.')
  47.         print(f'{average_standard_tickets:.2f}% standard tickets.')
  48.         print(f'{average_kids_tickets:.2f}% kids tickets.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement