Lompat ke konten Lompat ke sidebar Lompat ke footer

Program Python Pola Bintang Berbentuk Segitiga


Program 1

a = 5
for i in range(0, a):
    for j in range(0, i+1):
        print('* ' ,end='')
    print('')

Hasil Program 1

* * 
* * * 
* * * * 
* * * * * 


Program 2

a = 6
for i in range(0, a):
    for j in range(0, a-1):
        print('* ' ,end='')
    a -= 1
    print('')

Hasil Program 2

* * * * * 
* * * * 
* * * 
* * 



Program 3

a = 5
s = 2 * a-2
for i in range(0, a):
    for j in range(0, s):
        print(' ', end='')
    s -= 2
    for j in range(0, i+1):
        print('* ', end='')
    print('')

Hasil Program 3 

            *
         * *
      * * * 
    * *   * 
  * * *  * 
* * * * * 


Program 4

a = 5
s = 0
for i in range(0, a):
    for j in range(0, s):
        print(' ', end='')
    s += 2
    for j in range(0, a):
        print('* ', end='')
    a -= 1
    print('')

Hasil Program 4

* * * * * 
  * * *  * 
    * * ** 
      * * * 
        *  * 
            *



Student Terpelajar
Student Terpelajar Content Creator, Video Creator and Writer

Posting Komentar untuk "Program Python Pola Bintang Berbentuk Segitiga"