Project

Traffic Light (Python)

Hard
89 completions
~ 16 hours
3.9

By the end of this project, in addition to creating your own "traffic light", you will learn how to work with multi-threading, handle exceptions, inherit classes, and implement and apply the circular queue data structure

Provided by

JetBrains Academy JetBrains Academy

About

Do you know how traffic lights were invented? Some time ago, it was decided to replace the traffic police officers with a looped automated system that gives information to drivers about whether they can continue driving or not. In this project, we will implement a simplified version of such a system for a road junction in which many roads converge to one.

Graduate project icon

Graduate project

This project covers the core topics of the Python with Algorithms for Tech Interviews course, making it sufficiently challenging to be a proud addition to your portfolio.

At least one graduate project is required to complete the course.

What you'll learn

Once you choose a project, we'll provide you with a study plan that includes all the necessary topics from your course to get it built. Here’s what awaits you:
Good traffic light knows how many roads it controls and the interval between the opening and closing of the road. Input these two values to a program and implement the looped menu's option selection with simple stubs.
What if the user inputs "Hello" as the number of roads? The program will terminate with an exception, but the good traffic light should not stop working because of the user's mistake. Handle it and print the appropriate feedback.
Let's continue working with our menu. When the initial settings are provided, create a new thread that will start counting the seconds.
Let's give users the option to add and delete new roads. Roads open in a cyclical order, so don't forget to implement the circular queue as a buffer to store elements.
Our traffic light doesn't work as expected; it only shows the information about roads that were added to a road junction. Each time the system updates the output, calculate the exact time to close/open for each road.

Reviews

Igor Begunov avatar
Igor Begunov
1 year ago
How to use Thread module.And lost days because of poor desription.
Neoui avatar
Neoui
2 years ago
I have acquired basic knowledge of threading and also learned to work with 'circular' structures. This project has been quite challenging overall, but it has had a positive effect on my learning.
Natalia Shishina
2 years ago
Did not like the project. Wasted too much time because description is so vague, just examples help, but it needs to be described way better

3.9

Learners who completed this project within the Python with Algorithms for Tech Interviews course rated it as follows:
Usefulness
4.5
Fun
4.0
Clarity
3.4