1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| import random
def sapin(n):
print ((2*n - 2)*" " + "*")
print ((2*n - 2)*" " + "^")
for k in range(1, n):
leaf_1 = ("'" + '"')*(k - 1)
leaf_2 = ('"' + "'")*(k - 1)
christmas = ""
finish_2 = str(random.choices(['"', "o"], weights = (5, 1)))
finish_1 = str(random.choices(["'", "o"], weights = (5, 1)))
if k%2 == 0:
for x in leaf_2:
if x == '"':
christmas += str(random.choices(['"', "o"], weights = (5, 1)))
else:
christmas += str(random.choices(["'", "o"], weights = (5, 1)))
print (((2*n - 2) - k)*" " + "/" + christmas[2:len(christmas):5] + finish_2[2] + "\\")
else:
for y in leaf_1:
if y == '"':
christmas += str(random.choices(['"', "o"], weights = (5, 1)))
else:
christmas += str(random.choices(["'", "o"], weights = (5, 1)))
print (((2*n - 2) - k)*" " + "/" + christmas[2:len(christmas):5] + finish_1[2] +"\\")
for p in range(3):
print ((2*n - 3)*" " + "|||")
sapin(20) |
Partager