A theater seating chart is implemented as a table of ticket
Solution
Here is the code for you:
#!/usr/bin/python
seatPrices = [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
[10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
[10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
[10, 10, 20, 20, 20, 20, 20, 20, 10, 10],
[10, 10, 20, 20, 20, 20, 20, 20, 10, 10],
[10, 10, 20, 20, 20, 20, 20, 20, 10, 10],
[20, 20, 30, 30, 30, 30, 30, 30, 20, 20],
[20, 30, 30, 40, 50, 50, 40, 30, 30, 20],
[30, 40, 50, 50, 50, 50, 50, 50, 40, 30],
[20, 40, 50, 50, 50, 50, 50, 50, 40, 20]]
numOfSeatsOrdered = 0
amountOrdered = 0
while True:
for i in range(1, 10):
print seatPrices[i]
print \'1. Pick a seat.\'
print \'2. Pick a price.\'
print \'3. Quit\'
choice = input(\'Enter your choice: \')
if choice == 1:
row = input(\'Enter the row: \')
col = input(\'Enter the col: \')
if seatPrices[row][col] == 0:
print \'The seat is readily booked. Choose other seat.\'
else:
numOfSeatsOrdered += 1
amountOrdered += seatPrices[row][col]
seatPrices[row][col] = 0
elif choice == 2:
seatBooked = False
price = input(\'Enter the price to book: \')
for i in range(1, 10):
for j in range(1, 10):
if seatPrices[i][j] == price and seatBooked == False:
numOfSeatsOrdered += 1
amountOrdered += seatPrices[i][j]
seatPrices[i][j] = 0
seatBooked = True
elif choice == 3:
print \'Total number of tickets sold: \', numOfSeatsOrdered
print \'Total amount accumulated: \', amountOrdered
break
