135k views
5 votes
Create a method called print_seating_area that shows the seats that have

been sold, and the seats that are still available. Display available seats with the character
‘O’ and the sold seats with ‘X’. Call this method when the user selects ‘2’ in the main menu

1 Answer

3 votes

Answer:

Step-by-step explanation:

Here is an example implementation of the print_seating_area method in Python:

def print_seating_area(seats_sold):

# Define the seating arrangement as a list of lists

seating = [['O', 'O', 'O', 'O', 'O'],

['O', 'O', 'O', 'O', 'O'],

['O', 'O', 'O', 'O', 'O'],

['O', 'O', 'O', 'O', 'O'],

['O', 'O', 'O', 'O', 'O']]

# Mark seats that have been sold with an 'X'

for seat in seats_sold:

row, col = seat

seating[row][col] = 'X'

# Print the seating arrangement

print("Seats Sold: ")

for row in seating:

print(" ".join(row))

This method takes a list of tuples representing the seats that have been sold as its argument. It first initializes a list of lists representing the seating arrangement, with all seats initially marked as available ('O').

It then updates the seating arrangement by marking seats that have been sold with an 'X'. Finally, it prints out the seating arrangement, with sold seats represented by an 'X' and available seats represented by an 'O'.

To call this method when the user selects option 2 in the main menu, you can simply include the following code in your main program:

if choice == '2':

print_seating_area(seats_sold)

Here, seats_sold is a list of tuples representing the seats that have been sold, and choice is the user's input from the main menu. When choice is '2', the print_seating_area method is called with seats_sold as its argument, which displays the current seating arrangement.

User Whlk
by
8.5k points

No related questions found