#latihan logic
def deret_satu():
#input
n1 = int(input("masukan Nilai n1: ")
#nilai_tengah
nt = (n1/2)
#array2d
array2d = [[0 for x in range (n1)]for y in range(n1)]
#Perulangan
for i in range(0,n1):
for j in range (0,n1):
if(i<=j and i<=nt):
array2d[i][j] = print("O", end=' ')
elif(i>=j and j>=nt):
array2d[i][j] = print("O", end=' ')
else:
array2d[i][j] = print(" ", end=' ')
print()#spasi
if __name__ == '__main__':
deret_satu()
#Hasil keluaran
'''masukan nialai n1 : 9
O
O O
O O O
O O O O
O O O O O O O O O
O O O O
O O O
O O
O
'''
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.