patterns
import random
import numpy as np
def random_matrix(matrix_width,matrix_height):
matrix=[]
for i in range(matrix_width*matrix_height):
matrix.append(random.randint(0,100))
return (matrix)
def form_dna(max_width):
for i in range(max_width):
if i>max_width/2:
spacing=max_width-i
else:
spacing=i-1
if i==1 or i==max_width:
print(f"{' '*40}0")
elif i%2==0:
print(f"{' '*(40-spacing)}0{' '*spacing*2}0")
else:
print(f"{' '*(40-spacing)}0{'0'*spacing*2}0")
if __name__ == '__main__':
while True:
form_dna(20)
Comments
Post a Comment