#deret bintang
def deret():
num = int(input('Masukan jumlah deret: '))
for i in range(1,num):
for j in range(1, i+1):
print('*' , end=' ')
print() #spasi bawah
#deret angka
def deret_angka():
num = int(input('Masukan jumlah deret: ' ))
for i in range(1,num):
for j in range(1,i+1):
print('%d' % (i*j), end= ' ')
print() #spasi bawah
#metode asli
if __name__ == '__main__':
deret()
deret_angka()
#output
'''Masukan jumlah deret: 5
*
* *
* * *
* * * *
Masukan jumlah deret: 5
1
2 4
3 6 9
4 8 12 16'''
Belajar Dari yang dasar :)
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.