Member-only story
Wish Merry Christmas using Python
2 min readDec 25, 2024
from colorama import Fore, Style
import numpy as np
z = np.column_stack((np.arange(15, 6, -1), np.arange(1, 18, 2)))
[print(Fore.GREEN + ' '*i + Fore.GREEN + '*'*j +
Style.RESET_ALL) for i, j in z]
[print(Fore.RED + ' '*13 + ' || ' +
Style.RESET_ALL) for _ in range(3)]
print(Fore.BLUE + ' '*11 + r'\======/' + Style.RESET_ALL)
Imports
from Colorama import Fore, Style
:
Fore
is used to set the foreground (text) color.Style
is used to reset text styles to default.
import numpy as np
:
numpy
is imported for its efficient numerical operations.
Step 1: Generate Data with np.column_stack
z = np.column_stack((np.arange(15, 6, -1), np.arange(1, 18, 2)))
np.arange(15, 6, -1)
creates a sequence from 15 down to 7, decrementing by 1:
Output:[15, 14, 13, ..., 7]
.np.arange(1, 18, 2)
creates a sequence of odd numbers from 1 to 17:
Output:[1, 3, 5, ..., 17]
.np.column_stack
combines these two sequences into columns to form pairs:
Output:[[15, 1], [14, 3], [13, 5], ... [7, 17]]