Last active
December 28, 2019 02:53
-
-
Save onitonitonito/d1cac8fb7a07229b238bf4534efea41b to your computer and use it in GitHub Desktop.
Some modification on package file
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
""" | |
# 3년전 이맘때 쯤, 블링킹 xmas 트리 | |
""" | |
import os | |
import time | |
import random | |
# print(__doc__) | |
filler = '.' | |
width_ground = 50 | |
ornaments_list = ('*' * 3).join('o$@#&') | |
def main(): | |
while True: | |
# Blinking Xmas Tree | |
for n in range(1, 40, 2): | |
if n <= 3: | |
string = '*' * n | |
else: | |
inner = "" | |
for x in range(n - 2): | |
inner += random.choice(ornaments_list) | |
string = '*' + inner + '*' | |
print(string.center(width_ground, filler)) | |
# Tree trunk & Stand | |
print('W'.center(width_ground, filler)) | |
print('W'.center(width_ground, filler)) | |
print('W'.center(width_ground, filler)) | |
print(('#' * 19).center(width_ground, filler)) | |
# wait 0.3 sec & clear screen | |
time.sleep(0.5) | |
os.system('cls') | |
if __name__ == '__main__': | |
main() |
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
""" | |
# 3년 전 이 맘때, ... 쓸 데 없이 복잡! | |
# http://bit.ly/37k5HQf | |
""" | |
# https://gist.github.com/onitonitonito/d1cac8fb7a07229b238bf4534efea41b | |
import os | |
import time | |
ground_width=60 | |
def main(): | |
growing_corn_shape_tree() | |
time.sleep(1) | |
clear() | |
whole_xmas_tree(ground_width) | |
def clear(): | |
print("\n\n"*50) | |
def set_starbucks(tree_base_width): | |
print(("STAR").center(tree_base_width)) | |
print(("BUCKS").center(tree_base_width)) | |
def triangle(tree_leaf_end, tree_base_width): | |
for x in range(1,tree_leaf_end+1, 2): | |
print(("*"*x).center(tree_base_width)) | |
def trapezoid(tree_leaf_start, tree_leaf_end, tree_base_width): | |
for x in range(tree_leaf_start, tree_leaf_end+1, 2): | |
print(("*"*x).center(tree_base_width)) | |
def trunk(tree_trunk_height, tree_base_width): | |
for x in range(tree_trunk_height): | |
print(("|"*1).center(tree_base_width)) | |
def ground(tree_base_width): | |
print(("M"*tree_base_width).center(tree_base_width)) | |
print(("Christmas season just is around the corner!").center(tree_base_width)) | |
print("TREE SIZE = %s"%tree_base_width,"!!!","\n\n") | |
def corn_shape_tree(tree_leaf_end, tree_trunk_height, tree_base_width): | |
"""# whole corn shape tree""" | |
triangle(tree_leaf_end, tree_base_width) | |
trunk(tree_trunk_height, tree_base_width) | |
ground(tree_base_width) | |
def growing_corn_shape_tree(): | |
#order_leaf = [10, 20, 30, 40, 50, 60, 70, 80, 90,] | |
#order_trunk = [1, 2, 3, 4, 5, 6, 7, 8, 9,] | |
order_leaf = [x for x in range(10, 45, 5)] | |
order_trunk = [x for x in range(1, 8, 1)] | |
tree_base_width = int( order_leaf[-1]* 1.40 ) # 140% of last biggest width | |
for leaf_step, trunk_height in zip(order_leaf, order_trunk): | |
clear() # with script or IDLE screen | |
# os.system('cls') # with CMD screen | |
set_starbucks(tree_base_width) | |
corn_shape_tree(leaf_step, trunk_height, tree_base_width) | |
time.sleep(0.5) | |
print('order_leaf=',order_leaf) | |
print('order_trunk=',order_trunk) | |
print("ground_width(last order_leaf * 140%%) = %s"% tree_base_width) | |
print() | |
def whole_xmas_tree(ground_width): | |
set_starbucks(ground_width) | |
triangle(15, ground_width) | |
trapezoid(7,20,ground_width) | |
trapezoid(12,30,ground_width) | |
trunk(3, ground_width) | |
ground(ground_width) | |
if __name__ == '__main__': | |
main() |
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
""" | |
# 이맘 때, 한번 쯤 만들어 보는 Xmas 트리 - 생활코딩 | |
# http://bit.ly/2EXwk1r | |
""" | |
# https://www.facebook.com/photo.php?fbid=3199985326694503 | |
# &set=gm.3602534863120357&type=3&theater&ifg=1 | |
import os | |
import time | |
from random import random | |
# print(__doc__) | |
rate_globes = 0.2 | |
width = 16 | |
def main(): | |
while 1: | |
xmas_tree(width, rate_globes) | |
time.sleep(0.5) | |
os.system('cls') | |
def xmas_tree(width, rate_globes): | |
"""c = center / e = exterior """ | |
c = lambda x: print(x.center(width)) | |
e = lambda : 'o' if random() < rate_globes else '*' | |
# [c(r) for r in 'A-< >-V'.split('-')] # ... original | |
[c(r) for r in 'A-starbugs-V'.split('-')] | |
[c(''.join(e() for _ in range(i))) for i in range(3,width,2)] | |
[c(r) for r in r'| |-| |-_/_|_\_'.split('-')] | |
c('^'*width) | |
if __name__ == '__main__': | |
main() |
2. Result of growing tree
STAR
BUCKS
*
***
*****
*******
*********
***********
*************
***************
*****************
*******************
*********************
***********************
*************************
***************************
*****************************
*******************************
*********************************
***********************************
*************************************
***************************************
|
|
|
|
|
|
|
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
Christmas season just is around the corner!
TREE SIZE = 56 !!!
order_leaf= [10, 15, 20, 25, 30, 35, 40]
order_trunk= [1, 2, 3, 4, 5, 6, 7]
ground_width(last order_leaf * 140%) = 56
have to run these in the terminal screen due to os.system('cls')
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
1. Result of xmas tree