def deret_bintang():
n1 = int(input('Masukan nilai n1: '))
nt = (n1/2)
array2d = [[0 for x in range(n1)]for y in range(n1)]
v = int(1)
for i in range(0,n1):
for j in range(0,n1):
if(i==j or i+j==n1-1):
array2d[i][j]= print(z,end=' ')
elif(i==nt):
array2d[i][j]= print(z,end=' ')
elif(j==nt):
array2d[i][j]= print(v,end= ' ')
else:
array2d[i][j]= print(' ',end=' ')
z=z+2
print()#spasi
v = v+2
if __name__ == '__main__':
deret_bintang()
#Output:
'''
Masukan nilai n1: 9
1 1 17
3 3 15
5 5 13
7 7 11
1 3 5 7 9 11 13 15 17
7 11 11
5 13 13
3 15 15
1 17 17
'''
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.