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.

16,631 thoughts on “Contoh Soal Pemrograman – Pola Segitiga Siku-siku

  1. Its like you read my mind! You seem to know a lot about this, like you wrote the book in it or something.
    I think that you could do with some pics to drive
    the message home a bit, but instead of that, this is magnificent
    blog. A great read. I will certainly be back.

  2. What’s up to every body, it’s my first pay a quick
    visit of this weblog; this weblog consists of remarkable and actually good stuff
    in support of readers.

  3. I’ve been surfing online more than 2 hours today, yet I never found any interesting article like yours.
    It is pretty worth enough for me. In my view, if all webmasters and bloggers made
    good content as you did, the web will be much more useful than ever before.

  4. You could certainly see your expertise within the article you write.

    The sector hopes for even more passionate writers like you who are not afraid to mention how they
    believe. At all times go after your heart.

  5. I was wondering if you ever thought of changing
    the structure of your site? Its very well written; I love what youve got to say.
    But maybe you could a little more in the way of content so people
    could connect with it better. Youve got an awful lot of text for only having 1
    or 2 pictures. Maybe you could space it out better?

  6. Appreciating the commitment you put into your site and detailed information you
    present. It’s nice to come across a blog every once in a
    while that isn’t the same out of date rehashed material.
    Wonderful read! I’ve bookmarked your site and I’m adding your RSS feeds to
    my Google account.

  7. Wow that was strange. I just wrote an extremely long comment but after I clicked submit my
    comment didn’t show up. Grrrr… well I’m not writing all that
    over again. Anyways, just wanted to say excellent blog!

  8. Hello there, I think your site may be having internet browser compatibility problems.

    Whenever I take a look at your web site in Safari, it looks fine but when opening in Internet Explorer, it has some overlapping issues.
    I simply wanted to give you a quick heads up! Aside from that, great blog!

  9. I’ve been surfing online more than 4 hours today, yet I never found any interesting article like
    yours. It is pretty worth enough for me. Personally,
    if all webmasters and bloggers made good content as you
    did, the net will be a lot more useful than ever
    before.

  10. Excellent blog here! Also your site loads up very fast! What web host are you using?
    Can I get your affiliate link to your host? I wish my web site loaded up as fast as yours lol

  11. That is very interesting, You’re a very professional blogger.
    I’ve joined your feed and look forward to in the
    hunt for extra of your wonderful post. Also, I’ve
    shared your web site in my social networks

Comments are closed.