CarrotLesson/main.py
2023-08-16 00:16:57 +03:00

50 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from random import randint
from colorama import Fore, Back, Style, init as coloramaInit
gryadka = []
# "л" - лунка
# "м" - молодая морковка
# "М" - созревшая морковка
# "ж" - жук
# "" - пустая ячейка
gс_types = ["л", "м", "М", "ж", ""]
def generate_random_gryadka(gl: int):
# сгенерировать случайную грядку
gryadka.clear()
for i in range(gl):
gryadka.append(gс_types[randint(0, len(gс_types)-1)])
def print_slot(val: str):
# Напечатать ячейку грядки
if val == "м":
print(Fore.WHITE, Back.GREEN, "м ", end="")
elif val == "М":
print(Fore.RED, Back.YELLOW, "М ", end="")
elif val == "л":
print(Fore.CYAN, Back.BLACK, "л ", end="")
elif val == "ж":
print(Fore.WHITE, Back.RED, "ж ", end="")
else:
print(Fore.BLUE, Back.BLACK, " ", end="")
def printCell(val: str):
print_slot(val)
print(Style.RESET_ALL, end="")
def print_gryadka():
for v in gryadka:
printCell(v)
print()
if __name__ == "__main__":
coloramaInit()
generate_random_gryadka(20)
print_gryadka()