Contoh Soal Pemrograman – Pola Segitiga Siku-siku

Pemrograman Python

Pada posting sebelumnya sudah dicontohkan soal pemrograman dalam bahasa Python. Kali ini, akan ditampilkan lagi contoh berikutnya.

Soal:
Buatlah program Python untuk menampilkan pola segitiga siku-siku menggunakan forin.

Jawab:

Pola 1

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

Jawab:

siku_siku_1.py
tinggi = 6

for baris in range(0, tinggi):
    for kolom in range(0, tinggi-baris):
        print("*", end=" ")
    print("")

 

Pola 2

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

Jawab:

siku_siku_2.py
tinggi = 6

for baris in range(0, tinggi):
    for kolom in range(0, baris+1):
        print("*", end=" ")
    print("")

Pola 3

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

Jawab:

siku_siku_3.py
tinggi = 6

for baris in range(0, tinggi):
    for kolom in range(1, tinggi-baris):
        print(" ", end=" ")
    for bintang in range(0, baris+1):
        print("*", end=" ")
    print("")

Demikian contoh pola segitiga dalam pemrograman Python. Semoga bermanfaat.

48,517 thoughts on “Contoh Soal Pemrograman – Pola Segitiga Siku-siku

  1. Way cool! Some extremely valid points! I appreciate you writing this
    article plus the rest of the website is also very
    good.

  2. My spouse and I stumbled over here from a different web page and thought I might as well check things
    out. I like what I see so i am just following you. Look forward to
    finding out about your web page yet again.

  3. Thanks for your marvelous posting! I definitely enjoyed reading it, you might be a great author.
    I will make certain to bookmark your blog and will eventually come
    back in the future. I want to encourage you to ultimately continue your great work, have a nice holiday weekend!

  4. Undeniably believe that which you said. Your favorite reason appeared
    to be on the web the easiest thing to be aware of.
    I say to you, I certainly get irked while people consider worries that they just do not know about.
    You managed to hit the nail upon the top and defined out the whole thing without having side-effects ,
    people could take a signal. Will likely
    be back to get more. Thanks

  5. It’s amazing to pay a visit this website and reading the views of
    all friends regarding this post, while I am also zealous of getting experience.

Comments are closed.