From 64bd3ddc7f092549bb65139e4b19e6b7ab2cbf2b Mon Sep 17 00:00:00 2001 From: Rimas Alshahrani Date: Tue, 3 Mar 2026 01:54:54 +0300 Subject: [PATCH] solution lab_pip_venv --- bonus.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ main.py | 7 +++++++ 2 files changed, 54 insertions(+) create mode 100644 bonus.py create mode 100644 main.py diff --git a/bonus.py b/bonus.py new file mode 100644 index 0000000..8c02a57 --- /dev/null +++ b/bonus.py @@ -0,0 +1,47 @@ +from art import text2art +from colorama import Fore, Style, init +import time +import os + +# initialize colorama +init(autoreset=True) + +def clear_screen(): + os.system("cls" if os.name == "nt" else "clear") + +def show_banner(): + banner = text2art("TRAFFIC LIGHT", font="slant") + print(Fore.CYAN + Style.BRIGHT + banner) + +def show_signal(text, font, color, delay): + art_text = text2art(text, font=font) + border = "=" * 60 + print(color + Style.BRIGHT + border) + print(color + art_text) + print(color + border) + time.sleep(delay) + +def traffic_light_cycle(): + signals = [ + ("STOP", "block", Fore.RED, 3), + ("READY", "sub-zero", Fore.YELLOW, 2), + ("GO", "big", Fore.GREEN, 3), + ] + + for text, font, color, delay in signals: + clear_screen() + show_banner() + show_signal(text, font, color, delay) + + +try: + while True: + traffic_light_cycle() + + choice = input("\nPress Enter to continue or (q) to quit: ").lower() + if choice == "q": + print("\nProgram stopped safely ") + break + +except KeyboardInterrupt: + print("\n\nProgram terminated by user (Ctrl + C) ") \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..e170bd8 --- /dev/null +++ b/main.py @@ -0,0 +1,7 @@ +from art import text2art + +art1 = text2art("BELIEVE AND ACHIEVE", font="block") +print(art1) + +art2 = text2art("HELLO", font="sub-zero") +print(art2)