If you want to use the same script to print different patterns when running at different times, what you can do is write functions to print different patterns and then randomly call these functions. Refer to the example below:

import random
def pattern1():
n = 5
k = 2*n - 2
for i in range(0, n):
for j in range(0, k):
print(end=" ")
k = k - 1
for j in range(0, i+1):
print("* ", end="")
print("\r")

def pattern2():
n = 3
k = 2*n - 2
for i in range(0, n):
for j in range(0, k):
print(end=" ")
k = k - 1
for j in range(0, i+1):
print("* ", end="")
print("\r")

def pattern3():
n = 7
k = 2*n - 2
for i in range(0, n):
for j in range(0, k):
print(end=" ")
k = k - 1
for j in range(0, i+1):
print("* ", end="")
print("\r")

which=random.randint(1,3)
if which==1:
pattern1()
elif which==2:
pattern2()
else:
pattern3()