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. A motivating discussion is definitely worth comment.

    There’s no doubt that that you should write more on this subject, it may not be a taboo subject but
    usually folks don’t speak about such topics. To the next!
    Best wishes!!

  2. My brother recommended I might like this website.
    He was totally right. This post actually made my day.
    You cann’t imagine just how much time I had spent for this information! Thanks!

  3. Please let me know if you’re looking for a writer for
    your weblog. You have some really good articles and I think I would be a good asset.
    If you ever want to take some of the load off, I’d absolutely love to write some content for your blog in exchange for a link back to mine.
    Please shoot me an email if interested. Kudos!

  4. Hello would you mind letting me know which webhost you’re working with?
    I’ve loaded your blog in 3 different web browsers and I must say
    this blog loads a lot quicker then most. Can you recommend a good internet hosting provider at a fair price?
    Kudos, I appreciate it!

  5. Greetings from California! I’m bored at work so I decided to browse your blog on my iphone during lunch break.
    I love the knowledge you present here and can’t wait to take a look
    when I get home. I’m surprised at how fast your blog loaded
    on my phone .. I’m not even using WIFI, just 3G .. Anyways, superb site!

  6. hello there and thank you for your info – I have certainly picked up something new from right here.

    I did however expertise a few technical points using this site, as I experienced to reload
    the web site a lot of times previous to I could
    get it to load correctly. I had been wondering if your web hosting is OK?
    Not that I am complaining, but sluggish loading
    instances times will very frequently affect your placement in google
    and can damage your high-quality score if ads and marketing with Adwords.
    Well I’m adding this RSS to my e-mail and can look out for a lot more
    of your respective fascinating content. Make sure you update this again very soon. https://ivermectinforhumans.forsale/

  7. I blog frequently and I genuinely appreciate your information. This great article has really peaked my interest.
    I’m going to book mark your blog and keep checking for new details about once per week.
    I subscribed to your Feed as well.

  8. Heya i am for the primary time here. I found
    this board and I in finding It really helpful & it helped me out a lot.
    I’m hoping to give something again and aid others such as you helped
    me.

Comments are closed.