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,215 thoughts on “Contoh Soal Pemrograman – Pola Segitiga Siku-siku

  1. It’s appropriate time to make some plans for the future and it’s time to be happy.
    I’ve read this post and if I could I want to suggest you some interesting things
    or advice. Perhaps you can write next articles referring to this article.
    I wish to read even more things about it!

  2. Fastidious answer back in return of this issue with genuine
    arguments and describing the whole thing on the topic of that.

  3. What i do not realize is in truth how you’re no
    longer really much more neatly-appreciated than you may
    be right now. You’re very intelligent. You realize therefore considerably in the case of
    this matter, made me for my part consider it from so many varied angles.

    Its like women and men don’t seem to be interested except it’s something to accomplish with Lady gaga!

    Your individual stuffs outstanding. At all times take care of it
    up!

  4. Way cool! Some very valid points! I appreciate you writing this article and also the rest of the
    site is also very good.

  5. Very nice post. I just stumbled upon your blog and wanted to say that I’ve truly enjoyed browsing your blog posts.
    After all I’ll be subscribing to your rss feed
    and I hope you write again very soon!

Comments are closed.