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?
Module 4 Assignment 1: Pseudocode & Python with Variable Scope Overview Module 4 Assignment 1 features...
Module 4 Assignment 1: Pseudocode & Python with Variable Scope Overview Module 4 Assignment 1 features the design of a calculator program using pseudocode and a Python program that uses a list and functions with variable scope to add, subtract, multiply, and divide. Open the M4Lab1ii.py program in IDLE and save it as M4Lab1ii.py with your initials instead of ii. Each lab asks you to write pseudocode that plans the program’s logic before you write the program in Python and...
Part 1 Write a program that reads a line of input and display the characters between...
Part 1 Write a program that reads a line of input and display the characters between the first two '*' characters. If no two '*' occur, the program should display a message about not finding two * characters. For example, if the user enters: 1abc*D2Efg_#!*345Higkl*mn+op*qr the program should display the following: D2Efg_#! 1) Name your program stars.c. 2) Assume input is no more than 1000 characters. 3) String library functions are NOT allowed in this program. 4) To read a...
*PYTHON 3 * Coin taking game Game rules a) The game starts with 22 coins in...
*PYTHON 3 * Coin taking game Game rules a) The game starts with 22 coins in a common pool b) The goal of the game is to take the last coin c) Players take turns removing 1, 2, or 3 coins from the pool d) A player cannot take more coins than remain in the pool e) After each turn, the number of coins that remain in the pool is announced f) When the last coin is taken, the winner...
1. Draw a flowchart for a program that will compute the average of 10 exam scores...
1. Draw a flowchart for a program that will compute the average of 10 exam scores entered by the user. List the variables needed for this program. 2. Modify previous problem to allow the user to input the total number of exam scores. List the necessary variables and draw the flowchart. 3. Draw a flowchart for a program that will obtain 10 exam scores from the user and determine whether the score is passing (a score of 60 or above)...
Description: The purpose of this assignment is to practice writing code that calls functions, and contains...
Description: The purpose of this assignment is to practice writing code that calls functions, and contains loops and branches. You will create a C program that prints a menu and takes user choices as input. The user will make choices regarding different "geometric shapes" that will be printed to the screen. General Comments: Your code must contain at least one of all of the following control types: nested for() loops a while() or a do-while() loop a switch() statement an...
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...
15.20 Ch 9 Warm up: Parsing strings (C++) (1) Prompt the user for a string that...
15.20 Ch 9 Warm up: Parsing strings (C++) (1) Prompt the user for a string that contains two strings separated by a comma. (1 pt) Examples of strings that can be accepted: Jill, Allen Jill , Allen Jill,Allen Ex: Enter input string: Jill, Allen (2) Report an error if the input string does not contain a comma. Continue to prompt until a valid string is entered. Note: If the input contains a comma, then assume that the input also contains...
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.,...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT