Advertisement
svephoto

Cinema Tickets [Python]

Jan 9th, 2022 (edited)
1,324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.23 KB | None | 0 0
  1. movie_name = input()
  2. standard_tickets = 0
  3. kid_tickets = 0
  4. student_tickets = 0
  5.  
  6. while movie_name != 'Finish':
  7.     free_places = int(input())
  8.     current_movie_tickets = 0
  9.     ticket_type = ""
  10.  
  11.     while free_places > current_movie_tickets and ticket_type != 'End':
  12.         ticket_type = input()
  13.  
  14.         if ticket_type == 'standard':
  15.             standard_tickets += 1
  16.             current_movie_tickets += 1
  17.         elif ticket_type == 'student':
  18.             student_tickets += 1
  19.             current_movie_tickets += 1
  20.         elif ticket_type == 'kid':
  21.             kid_tickets += 1
  22.             current_movie_tickets += 1
  23.  
  24.     current_movie_percent = (current_movie_tickets / free_places) * 100
  25.     print(f"{movie_name} - {current_movie_percent:.2f}% full.")
  26.     movie_name = input()
  27.  
  28. total_tickets = student_tickets + standard_tickets + kid_tickets
  29.  
  30. avr_kid_percent = (kid_tickets / total_tickets) * 100
  31. avr_student_percent = (student_tickets / total_tickets) * 100
  32. avr_standard_percent = (standard_tickets / total_tickets) * 100
  33. print(f'Total tickets: {total_tickets}')
  34. print(f"{avr_student_percent:.2f}% student tickets.")
  35. print(f"{avr_standard_percent:.2f}% standard tickets.")
  36. print(f"{avr_kid_percent:.2f}% kids tickets.")
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement