Created
December 21, 2022 18:26
-
-
Save paoloinglese/ed5d8508490a2cf852cf315a8b0fcf0c to your computer and use it in GitHub Desktop.
A simple Christmas tree π
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import time | |
import random | |
def pt(h=10): | |
pg = 0.8 | |
lf = "*" | |
sy = ["@", "o", "Q"] | |
lc = ['\033[94m', '\033[93m', '\033[91m'] | |
bs = 1 | |
for i in range(h): | |
bs += 2 | |
hb = int(bs / 2) | |
ns = 1 | |
ou = "" | |
for n in range(h): | |
ss = hb - n | |
for i in range(ss): | |
ou += " " | |
for i in range(ns): | |
if random.random() <= pg: | |
ou += '\033[92m' + lf + '\033[0m' | |
else: | |
co = random.choice(lc) | |
ou += co + random.choice(sy) + '\033[0m' | |
ou += "\n" | |
ns += 2 | |
for i in range(hb - 1): | |
ou += " " | |
ou += "| |\n" | |
return ou | |
for i in range(10): | |
os.system("cls" if os.name == "nt" else "clear") | |
print(pt(), end="\r") | |
time.sleep(1) | |
print('\033[91m' + "Merry Christmas and Happy 2023" + '\033[0m') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment