-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCinema-Booking-Tool.txt
More file actions
48 lines (41 loc) · 1.4 KB
/
Cinema-Booking-Tool.txt
File metadata and controls
48 lines (41 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Option 1: Book a seat by row/column
# Option 2: Book a seat close to the front
# Option 3: Book a seat close to the back
def check_seat_availability(row, row_name):
for index, seat in enumerate(row):
if seat == 0:
return f"Seat {index + 1} in Row {row_name} is available"
def book_seat(row, row_name, seat_number):
if row[seat_number - 1] == 0:
row[seat_number - 1] = 1
return f"Row {row_name} is now {row}. You have selected seat {seat_number} in Row {row_name}."
else:
return "This seat is occupied."
# Seat rows
A = [1, 1, 0, 0, 1, 0, 0, 0]
B = [0, 1, 1, 0, 1, 0, 1, 0]
C = [0, 0, 1, 1, 0, 1, 0, 0]
# User input
print("Would you like a seat at the front? (Yes/No)")
front = input()
print("Would you like a seat at the back? (Yes/No)")
back = input()
# Check seat availability
if front.lower() == "yes":
print(check_seat_availability(A, 'A'))
if back.lower() == "yes":
print(check_seat_availability(C, 'C'))
print("Which row would you like? (A/B/C)")
row = input().upper()
# Book seat in the selected row
if row in ["A", "B", "C"]:
print("Which seat number?")
seat = int(input())
if row == "A":
print(book_seat(A, "A", seat))
elif row == "B":
print(book_seat(B, "B", seat))
elif row == "C":
print(book_seat(C, "C", seat))
else:
print("Invalid row selected."