Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. #liljas17@ru.is and stefana19@ru.is
  2. SPACE = ' '
  3.  
  4. def get_num_rows():
  5. '''Prompts user for numbers of rows '''
  6. num_rows = int(input('Enter number of rows: '))
  7.  
  8. return num_rows
  9.  
  10. def get_num_seats():
  11. ''' Prompts user asking how many seats in each row '''
  12. num_seats = int(input('Enter number of seats in each row: '))
  13.  
  14. return num_seats
  15.  
  16. def get_seating(rows, seats):
  17. ''' Creates seating arrangement with single alphabet character for each seat '''
  18. seating =[]
  19. for i in range(rows):
  20. all_rows = []
  21. for j in range(65, 90):
  22. seat = chr(j)
  23. all_rows.append(seat)
  24. seating.append(all_rows)
  25. return seating
  26.  
  27. def print_seating(rows, seats, seating):
  28. '''
  29. Prints out the seating arrangement in accordance with the number of rows and seats per row
  30. We created the constant SPACE as a single space, simply because it's easier to see and
  31. troubleshoot for exact spacing in Mimir
  32. '''
  33. seating_num = 0
  34. for i in range(rows):
  35. seating_num += 1
  36. print('{:>2}{}'.format(seating_num, SPACE*3), end = '')
  37. for j in range(seats):
  38. seats_l = seating[i][j]
  39. print('{:}{}'.format(SPACE, seats_l), end = '')
  40. for j in range(seats, seats + 1):
  41. print(end = ' ')
  42. for j in range(seats, seats * 2):
  43. seats_r = seating[i][j]
  44. print('{:}{}'.format(SPACE, seats_r), end = '')
  45. print()
  46.  
  47.  
  48. def choose_seat(seating):
  49. ''' Prompts the user for a seat to reserve on the plane. This function is unfinished '''
  50. input_choice = input('Input seat number (row seat): ')
  51. seat_choice = input_choice.split()
  52. if seat_choice != seating:
  53. print('Seat number is invalid!')
  54. elif seat_choice == 'X':
  55. print('That seat is taken!')
  56. else:
  57. print()
  58.  
  59. return seat_choice
  60.  
  61. def main():
  62. rows = get_num_rows()
  63. seats = get_num_seats()
  64. org_seating = get_seating(rows, seats)
  65. print_seating(rows, seats, org_seating)
  66. #seat_choice = choose_seat(org_seating)
  67. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement