Вот пример того, как можно создавать шаблоны в Python с помощью цикла while:
Метод 1: Треугольный узор
rows = int(input("Enter the number of rows: "))
i = 1
while i <= rows:
print('*' * i)
i += 1
Метод 2: квадратный узор
rows = int(input("Enter the number of rows: "))
i = 1
while i <= rows:
print('*' * rows)
i += 1
Метод 3: числовой шаблон
rows = int(input("Enter the number of rows: "))
i = 1
num = 1
while i <= rows:
print(str(num) * i)
i += 1
num += 1
Метод 4: ромбовидный узор
rows = int(input("Enter the number of rows: "))
i = 1
while i <= rows:
print(' ' * (rows - i) + '*' * (2 * i - 1))
i += 1
i = rows - 1
while i >= 1:
print(' ' * (rows - i) + '*' * (2 * i - 1))
i -= 1
Метод 5: прямоугольный треугольник
rows = int(input("Enter the number of rows: "))
i = 1
while i <= rows:
print('*' * i)
i += 1