4Geeks logo
About us

Learning library

For all the self-taught geeks out there, here is our content library with most of the learning materials we have produced throughout the years.

It makes sense to start learning by reading and watching videos about fundamentals and how things work.

Data Science and Machine Learning - 16 wks

Full-Stack Software Developer - 16w

Search from all Lessons

Social & live learning

The most efficient way to learn: Join a cohort with classmates just like you, live streams, impromptu coding sessions, live tutorials with real experts, and stay motivated.

← Back to Projects

Queue Managment CLI with Python

Goal

4Geeks Coding Projects tutorials and exercises for people learning to code or improving their coding skills

Difficulty

intermediate

Repository

Click to open

Video

Not available

Live demo

Not available

Average duration

8 hrs

Technologies

alt text Queue Management System CLI

Lets create a Queue System: Queue system are heavily used in Goverment institutions, airports, banks and many other venues looking to organize the incoming traffic. Queue systems can also be used to load balancing for different applications like:

  • Establishing priorities in web servers incoming requests.
  • Immigration and visa applicantions that need to be prioritized.
  • Network packages.
  • etc.

A queue is just a list of elements that must be processed in a particular order: FIFO and FILO.

Today we are going to build a Queue system with FIFO approach for restaurants: If a new clients arrives to the restaurant their phone number is added into a queue, when it is his time to eat, he gets notified by email.

🌱 How to start this project

  1. This project comes with the necessary files to start working, but you have two options to start:

a) Use gitpod: open this link in your browser to clone it with gitpod: https://gitpod.io#https://github.com/breatheco-de/exercise-queue-management-cli-python.

b) You can clone this repository on your local computer:

1$ git clone https://github.com/breatheco-de/exercise-queue-management-cli-python
  1. Install dependency packages $ pipenv install

  2. Get inside the environment by typing $ pipenv shell

  3. You can run the current project by typing $ python src/app.py

πŸ’‘ Important: Remember to create a new repository, update the remote (git remote set-url origin <your new url>), and upload the code to your new repository using add, commit and push.

πŸ“ Instructions

Start coding! Update the app.py file to allow the user to manage a simple Queue: Add a person, Remove person, get current line (queue):

  • The application also needs to be able to export the queue to a file named queue.json.
  • The application must integrate with the twilio API to send an SMS every time a phone number is dequeued.
  • Use the following data-structure to implement the queue:
1class Queue: 2 3 def __init__(self, mode, current_queue=[]): 4 self.queue = current_queue 5 # depending on the _mode, the queue has to behave like a FIFO or LIFO 6 if mode is None: 7 raise "Please specify a queue mode FIFO or LIFO" 8 else: 9 self.mode = mode 10 11 def enqueue(self, item): 12 pass 13 def dequeue(self): 14 pass 15 def get_queue(self): 16 pass 17 def size(self): 18 return len(self.queue)

Example worlflow

  1. The CLI show the menu, and the user selects the option to add "Bob" into the queue.
  2. The application ads Bob and notifies confirmation on the console and must say how many people are in front of him on the line.
  3. The system now shows the menu (starts again) awaiting for the user to pick another option.
  4. If the user picks the option to remove from the Queue, the next person on the queue gets eliminated and confirmation message shows.
  5. The user must receive an SMS when it is his/her time to eat.
  6. If the user picks to see the entire queue state, a list of everyone gets printed with their respective position in the queue.
  7. If the user picks to export entire queue, a JSON file with a list of everyone gets created.

πŸ“– Fundamentals

This exercise will make you practice the following fundamentals:

  • Executing python files from the command line.
  • Get user input from the command line.
  • Loops, conditionals and functions.
  • Using plain-text files to store data.
  • Complex Data Structures.
  • Queue (FIFO vs FILO)
  • SMS.

Goal

4Geeks Coding Projects tutorials and exercises for people learning to code or improving their coding skills

Difficulty

intermediate

Repository

Click to open

Video

Not available

Live demo

Not available

Average duration

8 hrs