Visitor Tracking Program

# First, we define a list where the staff names will be stored staff =list() time_spent=list() # We define a variable for our main while-loop stop =False # Variable that tracks the state of the conversation talk_state=-1 # Start the main loop whilenot stop: iftalk_state==-1: # display menu print("Building Entrance Management") print("============================") print("1- Sign In") print("2- Sign Out") print("3- Report") print("0- Quit") # Now, we will start a second loop to check that the user enters a valid option valid_option=False whilenotvalid_option: choice =input("Choice? ") ifchoice.isnumeric() andint(choice) >=0andint(choice) <=3: # the option is numeric and is also between 0 and 3 talk_state=int(choice) valid_option=True else: print("Please enter a valid option.") eliftalk_state==0: # Quit iflen(staff) >0: print("There are still "+len(staff) +" person(s) in the building\n") valid_option=False whilenotvalid_option: choice =input("Are you sure you would like to exit the program? (y/n) ") if choice =='y': valid_option=True stop =True print("Good bye!") elif choice =='n': valid_option=True talk_state=-1 else: print("Please enter a valid option.") eliftalk_state==1: # Sign In name =input("Name: ") iflen(staff) ==5: print("Cannot allow more than 5 people!") else: staff.append(name) print("Entrance allowed!") talk_state=-1 eliftalk_state==2: # Sign out name =input("Name: ") if name in staff: # The entered name is present in the staff # Calculate time spent in minutes foridx, name_ inenumerate(staff): if name_ == name: time_min=input("Time Spent (in Minutes): ") time_spent.append(int(time_min)) print(name +" exited the building.") staff.remove(name) break else: print("This person is not in the building!") talk_state=-1 eliftalk_state==3: # Report print("There are "+str(len(staff)) +" person(s) in the building.") avg =0 iflen(staff) >0: foridx, name inenumerate(staff): print(str(idx+1) +" - "+ name) iflen(time_spent) >0: for mins intime_spent: avg += mins avg = avg/len(time_spent) print("People spend on average "+str(avg) +" minutes.") talk_state=-1 print("")