Draw a flowchart based on the Python code below:
ch = -1 #Variable declared for taking option entered by the user print("Enter 0 to 5 for following options: ") print("0-> Issue new ticket number.") print("1-> Assign first ticket in queue to counter 1.") print("2-> Assign first ticket in queue to counter 2.") print("3-> Assign first ticket in queue to counter 3.") print("4-> Assign first ticket in queue to counter 4.") print("5-> Quit Program.") tickets = [] #Declaring list to store tickets ticket = 1000 #Initializing ticket with value 10000 assignment ={"Counter 1":"Not assigned","Counter 2":"Not assigned","Counter 3":"Not assigned","Counter 4":"Not assigned"} while(ch!=5): #Running loop until user gives 5 as input as 5 option is for qutting the program print("Tickets in queue: ",tickets) #Printing the tickets in queue print("Counter assignment: ",assignment) #Printing dictionary displaying counter number and its respective ticket ch = int(input('Enter your option: ')) #Taking user input for option and storing in variable ch if(ch==0): #Case in which user enters option 0 ticket+=1 #Increment the ticket number by 1 tickets.append(ticket) #Append the ticket in list tickets elif(ch==1): #Case in which the user enters option 1 assignment["Counter "+str(ch)]=tickets[0] #Assigning first ticket in queue to counter 1 tickets.remove(tickets[0]) #Removing the assigned ticket from the queue elif(ch==2): #Case in which the user enters option 2 assignment["Counter "+str(ch)]=tickets[0] #Assigning first ticket in queue to counter 2 tickets.remove(tickets[0]) #Removing the assigned ticket from the queue elif(ch==3): #Case in which the user enters option 3 assignment["Counter "+str(ch)]=tickets[0] #Assigning first ticket in queue to counter 3 tickets.remove(tickets[0]) #Removing the assigned ticket from the queue elif(ch==4): #Case in which the user enters option 4 assignment["Counter "+str(ch)]=tickets[0] #Assigning first ticket in queue to counter 4 tickets.remove(tickets[0]) #Removing the assigned ticket from the queue elif(ch==5): #Case in which the user enters option 5 break #break statement to come out of loop hence quitting the program else: #Case in which user enters option other than the mentioned options print("Invalid option,try again...")
I've added ... for long print/assignment statements
Get Answers For Free
Most questions answered within 1 hours.