logo Use CA10RAM to get 10%* Discount.
Order Nowlogo

import random from collections import deque from time import sleep my_queue = deque([])

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

import random

from collections import deque

from time import sleep

 

my_queue = deque([])

 

def user_input():

    print("Menu")

    print("1. Register a customer")

    print("2. Call next customer")

    print("3. List customers in queue")

    print("0. Exit")

    menu_number = int(input("Please choose : "))

    if menu_number == 1:

        register_customer()

        user_input()

    elif menu_number == 2:

        call_customer()

        user_input()

    elif menu_number == 3:

        list_customers()

        user_input()

    elif menu_number == 0:

        return

 

def register_customer():

    customer_name = input("May I have your name please : ")

    if len(my_queue) == 0:

        

        my_queue.append({

        'customer': customer_name,'queue_no': random.randint(1,5)*100,'missedcalls': 0

    })

    else:

        my_queue.append({

        'customer': customer_name,'queue_no': my_queue[-1]['queue_no']+1 ,'missedcalls': 0

    })

    

def call_customer():

    customer_servedno = 0

    customer_served = []

    if len(my_queue) == 0:

        print("There are no customers in queue.")

    else:

        customer = my_queue.popleft()

        while customer_servedno >= 0 :

            print("Calling queue no" + "your waffle is ready")

            sleep(1)

            if random.randint(0,3) == 1:

                print (str(customer['queue_no']) +' '+ customer['customer'] +' ' + "has been served")

                customer_served.append(customer['customer'])

                customer_servedno += 1

            else:

                print("Has tried 3 times calling Queue number" + ' ' + str(customer['queue_no']))

                my_queue.append(customer)

                my_queue.append(customer['missedcalls']+1)

def list_customers():

    if len(my_queue) == 0:

        print("There are no customers in queue.")

    else:

        print("Queue Number\t" + my_queue['queue_no'] + "Customer Name\t" +  my_queue['customer'] + "No of missed calls\t" +  my_queue['missedcalls'])

user_input()

 

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

944 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

792 Answers

Hire Me
expert
Husnain SaeedComputer science

986 Answers

Hire Me
expert
Atharva PatilComputer science

922 Answers

Hire Me