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

  1. Hi, I do believe this is a great web site. I stumbledupon it 😉 I will revisit yet again since i
    have book-marked it. Money and freedom is
    the greatest way to change, may you be rich and continue to guide
    others.

  2. Its like you read my mind! You seem to know a lot about this, like
    you wrote the book in it or something. I believe that
    you just can do with a few % to pressure the message home a little
    bit, but other than that, that is fantastic blog.
    A great read. I’ll certainly be back.

  3. You can certainly see your enthusiasm within the article you write.
    The sector hopes for even more passionate writers
    such as you who are not afraid to say how they
    believe. At all times go after your heart.

  4. Just want to say your article is as astounding.
    The clarity on your submit is simply excellent and i
    can assume you are knowledgeable on this subject.
    Well with your permission allow me to seize your feed to keep updated
    with approaching post. Thanks 1,000,000 and please
    carry on the enjoyable work.

  5. I loved as much as you’ll receive carried out right here.
    The sketch is attractive, your authored material stylish.

    nonetheless, you command get got an nervousness over that
    you wish be delivering the following. unwell unquestionably come further formerly again since exactly the same nearly very often inside case you shield this hike.

Comments are closed.