def push_trail(N, myStack):
last_five = N[-5:]
for item in last_five:
myStack.append(item)
print("Last 5 elements pushed onto the stack.")
This function slices the last 5 elements from list N using N[-5:].
def pop_one(myStack):
if len(myStack) == 0:
print("Stack Underflow")
return None
else:
return myStack.pop()
This function first checks whether myStack is empty.
def display_all(myStack):
if len(myStack) == 0:
print("Empty Stack")
else:
for item in myStack:
print(item, end=" ")
print()
This function prints all items in myStack without modifying the stack.
PASSENGERS.DAT stores the records of passengers using the following structure:Create() – to input data for passengers and write it in the binary file PASSENGERS.DAT.SearchDestn(D) – to read contents from the file PASSENGERS.DAT and display the details of those Passengers whose DESTN matches with the value of D.UpdateFare() – to increase the fare of all passengers by 5% and rewrite the updated records into the file PASSENGERS.DAT.