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

  1. I blog frequently and I really thank you for your information. Your article has really
    peaked my interest. I will take a note of your website and keep checking for
    new details about once a week. I subscribed to your RSS feed as well.

  2. I will right away seize your rss feed as I can not to find your email subscription hyperlink
    or e-newsletter service. Do you’ve any? Please allow
    me recognise in order that I could subscribe.
    Thanks.

  3. Hmm it appears like your site ate my first comment (it was super long) so I guess
    I’ll just sum it up what I submitted and say,
    I’m thoroughly enjoying your blog. I as well am
    an aspiring blog writer but I’m still new to the whole thing.
    Do you have any tips and hints for newbie blog writers?
    I’d really appreciate it.

  4. Its such as you read my mind! You seem to know a lot about this, such as
    you wrote the book in it or something. I believe that you simply could do
    with a few % to power the message house a bit, but instead
    of that, that is wonderful blog. A fantastic read. I will certainly be back.

Comments are closed.