Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions bonus.py
Original file line number Diff line number Diff line change
@@ -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) ")
7 changes: 7 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -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)