Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Python Please!!! Given a file which contains the seat assignments of passengers separated by commas, write two functions: seat_assignments(filename) should take the name of the
Python Please!!!
Given a file which contains the seat assignments of passengers separated by commas, write two functions: seat_assignments(filename) should take the name of the file as input, read it, and return the contents of the file as a string. open_seat(seating) should take the contents of the file and return the seat closest to the front that's still available as a string. NOTE: there will only be one empty seat per row, and the closest row has the smallest number. Seats are strings in the form: number letter availability e.g. Unvailable: "17 c X" Available: "17 co" (the letter o, not the number zero) Sample File Structure: The file will be structured as follows: 16 a X,8 c X, 22 b X,10 c X, 30 d 0,14 b X, 24 e x,7 e x, 12 e X,27 b X,5 b 0,8 d x,14 c X And for this file your code should return: 5 bo Luau uelauil tempial! 1 def seat_assignments(filename): 2 # your code here! 3 pass 4 5 def open_seat(seating): 6 # your code here! 7 pass 8 9 if __name__ == "__main__": LO 11 seats = seat_assignments("seatchart.txt") 12 assertCopen_seat(seats) == "5 b 0")
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started