Membuat perulangan segitiga, piramida menggunakan python.
for i in range(5):
print (i)
print"---------"
for i in range(0,5):
for j in range(0,i):
print "*",
print ""
print"---------"
for i in range(0,5):
for j in range(i,5):
print "*",
print ""
print"---------"
for i in range(0,5):
for j in range(i,5):
print " ",
for k in range(0,i):
print "*",
print ""
print"--------"
for i in range(0,5):
for j in range(0,i):
print " ",
for k in range(i,5):
print "*",
print ""
print"----pidamida1----"
for i in range(0,5):
for j in range(i,5):
print " ",
for k in range(0,i):
print "*",
for l in range(0,i-1):
print "*",
print ""
print"----pidamida2----"
for i in range(0,5):
for j in range(0,i):
print " ",
for k in range(i,5):
print "*",
for l in range(i+1,5):
print "*",
print ""
No comments:
Post a Comment
Silahkan