Question

Draw a flowchart based on the Python code below: ch = -1 #Variable declared for taking...

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...")

Homework Answers

Answer #1

I've added ... for long print/assignment statements

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
CODE BLOCK D flag = 0 while flag == 0 : guess = input ("Select an...
CODE BLOCK D flag = 0 while flag == 0 : guess = input ("Select an option:\n1. Add a course\n2. Drop a course\n3. Print your registration.\n4. Quit\n\n>>> ") if guess.isdigit() : guess = int(guess) if guess == 1: print("Lets add a course") elif guess == 2: print("Lets drop a course") elif guess == 3: print("Lets print your registration") elif guess == 4: print("Bye") flag = 1 else: print(“Huh?”) If the user enters the value 5. What will print?
Python Blackjack Game Here are some special cases to consider. If the Dealer goes over 21,...
Python Blackjack Game Here are some special cases to consider. If the Dealer goes over 21, all players who are still standing win. But the players that are not standing have already lost. If the Dealer does not go over 21 but stands on say 19 points then all players having points greater than 19 win. All players having points less than 19 lose. All players having points equal to 19 tie. The program should stop asking to hit if...
write a code in python Write the following functions below based on their comments. Note Pass...
write a code in python Write the following functions below based on their comments. Note Pass is a key word you can use to have a function the does not do anything. You are only allowed to use what was discussed in the lectures, labs and assignments, and there is no need to import any libraries. #!/usr/bin/python3 #(1 Mark) This function will take in a string of digits and check to see if all the digits in the string are...
IN JAVA 1. Write up a small program that accepts two integers from the user. Print...
IN JAVA 1. Write up a small program that accepts two integers from the user. Print which of the two values is bigger. If they are the same, print that they are the same. 2. Write a method that accepts three doubles. Calculate and return the average of the three passed double values. 3. Write up a method that accepts a score between 0-10. Print out a message according to the following table. You ay personally decide the boundaries. i.e.,...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in Lab 2 to obtain a diameter value from the user and compute the volume of a sphere (we assumed that to be the shape of a balloon) in a new program, and implement the following restriction on the user’s input: the user should enter a value for the diameter which is at least 8 inches but not larger than 60 inches. Using an if-else...
Questions: 1. (5 marks) Create a VB.NET Console Application that defines a function Smallest and calls...
Questions: 1. Create a VB.NET Console Application that defines a function Smallest and calls this function from the main program. The function Smallest takes three parameters, all of the Integer data type, and returns the value of the smallest among the three parameters. The main program should (1) Prompt a message (using Console.WriteLine) to ask the user to input three integers. (2) Call the built-in function Console.ReadLine() three times to get the user’s input. (3) Convert the user’s input from...
Program will allow anywhere between 1 and 6 players (inclusive). Here is what your output will...
Program will allow anywhere between 1 and 6 players (inclusive). Here is what your output will look like: Enter number of players: 2 Player 1: 7S 5D - 12 points Player 2: 4H JC - 14 points Dealer: 10D Player 1, do you want to hit? [y / n]: y Player 1: 7S 5D 8H - 20 points Player 1, do you want to hit? [y / n]: n Player 2, do you want to hit? [y / n]: y...
Functions displayGrades and addGrades must be rewritten so that the only parameters they take in are...
Functions displayGrades and addGrades must be rewritten so that the only parameters they take in are pointers or constant pointers. Directions: Using the following parallel array and array of vectors: // may be declared outside the main function const int NUM_STUDENTS = 3; // may only be declared within the main function string students[NUM_STUDENTS] = {"Tom","Jane","Jo"}; vector <int> grades[NUM_STUDENTS] {{78,98,88,99,77},{62,99,94,85,93}, {73,82,88,85,78}}; Be sure to compile using g++ -std=c++11 helpWithGradesPtr.cpp Write a C++ program to run a menu-driven program with the...
C++ PROGRAMMING Assignment: For this assignment, you will construct a program which is capable of taking...
C++ PROGRAMMING Assignment: For this assignment, you will construct a program which is capable of taking a user-given number, and adding up all of the numbers between 1 and the given number. So if someone inputs 12, it should add 1 + 2 + 3 + 4 + … 9 + 10 + 11 + 12, and return the answer. However, you’ll be using two different methods to do this. The first method should utilize either a for loop or...
For this assignment, you will be creating a simple “Magic Number” program. When your program starts,...
For this assignment, you will be creating a simple “Magic Number” program. When your program starts, it will present a welcome screen. You will ask the user for their first name and what class they are using the program for (remember that this is a string that has spaces in it), then you will print the following message: NAME, welcome to your Magic Number program. I hope it helps you with your CSCI 1410 class! Note that "NAME" and "CSCI...