Pattern creation 1. reverse patter 2 Dimond patter

reverse pattern Code

line= “*”
space= " "
maxlength= 10

while len(line)<maxlength:
print(space*(int(maxlength-len(line)))+ line)
line = line+ “*”

line= line[:-1]

while len(line)>0:
line= line[:-1]
print(space*(int(maxlength-len(line)))+ line)

Code for Diamond Pattern

line= “*”
space= " "
maxlength= 10

while len(line)<maxlength:
print(space*(int((maxlength-len(line))/2))+ line +(space*(int(maxlength-len(line)/2))))
line = line+ “**”

line= line[:-2]

while len(line)>0:
line= line[:-2]
print(space*(int((maxlength-len(line))/2))+ line +(space*(int(maxlength-len(line)/2))))