From 33943233a1ad06b92a5e5bafce87f55125095d44 Mon Sep 17 00:00:00 2001 From: John Chever Date: Fri, 3 Dec 2021 09:58:47 +0800 Subject: [PATCH] Docs: HelloWorld From CheverJohn (#59) * Docs: HelloWorld From CheverJohn a interesting demo by python. * Docs: just update a .py file --- 2021/CheverJohn/MerryChristmas | 1 + 2021/CheverJohn/xmas.py | 53 ++++++++++++++++++++++++++++++++++ 2021/Signatures.txt | 1 + 3 files changed, 55 insertions(+) create mode 160000 2021/CheverJohn/MerryChristmas create mode 100644 2021/CheverJohn/xmas.py diff --git a/2021/CheverJohn/MerryChristmas b/2021/CheverJohn/MerryChristmas new file mode 160000 index 0000000..64a1c3d --- /dev/null +++ b/2021/CheverJohn/MerryChristmas @@ -0,0 +1 @@ +Subproject commit 64a1c3d2cd5aa1ed9999db5226a88ae09e8b2c6b diff --git a/2021/CheverJohn/xmas.py b/2021/CheverJohn/xmas.py new file mode 100644 index 0000000..6f3e9a1 --- /dev/null +++ b/2021/CheverJohn/xmas.py @@ -0,0 +1,53 @@ +import termcolor +import random +import time, datetime +import sys, os +from colorama import init +from termcolor import colored + +def clear(): + if sys.platform == 'win32': # if windows + return os.system('cls') + else: #if *nix + return os.system('clear') + + +colors = [ + 'red', + 'green', + 'yellow', + 'blue', + 'magenta', + 'cyan', + 'white'] + +yellowlight = termcolor.colored('o', 'yellow') +magentalight = termcolor.colored('o', 'magenta') +cyanlight = termcolor.colored('o', 'cyan') + +lightlist = [yellowlight, cyanlight, magentalight] + +init() +while True: #exit with ctrl+C + print('to exit use a keyboard interrupt (ctrl+c)') + for i in range(1,30,2): #tree + tree = '' + for j in range(i): #make lights + randNum=random.randint(0,500) + if (randNum <= 750) and (randNum >=250) : + tree += lightlist[random.randint(0,2)] + else: + tree += termcolor.colored('*', 'green') + string = '_'*(15-int(i/2))+tree+'_'*(15-int(i/2))+'\n' + print(string,end='') + trunk=colored('mWm', 'yellow') + for k in range(3): #trunk + outbuffer = '_'*14+trunk+'_'*14+'\n' + print(outbuffer, end='') + merry_Christmas =termcolor.colored('Merry Christmas', colors[random.randint(0,len(colors)-1)]) + outbuffer2 = '_'*8+merry_Christmas+'_'*8+'\n' + print(outbuffer2, end='') + time.sleep(0.4) + clear() + + \ No newline at end of file diff --git a/2021/Signatures.txt b/2021/Signatures.txt index 7bd3ee2..169d562 100644 --- a/2021/Signatures.txt +++ b/2021/Signatures.txt @@ -1,3 +1,4 @@ # Please sign your name below: # e.g.: GeMini-220 +CheverJohn TerrificTerry