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.

17,249 thoughts on “Contoh Soal Pemrograman – Pola Segitiga Siku-siku

  1. An intriguing discussion is definitely worth comment.
    I do believe that you ought to write more about this subject, it
    might not be a taboo subject but usually people don’t talk about these issues.

    To the next! Cheers!!

  2. Its such as you read my mind! You appear to grasp a
    lot about this, such as you wrote the guide in it or something.
    I feel that you just could do with some p.c.
    to power the message house a little bit, but other
    than that, that is fantastic blog. A great read. I will certainly be back.

  3. I’m impressed, I must say. Rarely do I come across a blog that’s equally educative and interesting, and without a doubt,
    you have hit the nail on the head. The issue is something that too few folks
    are speaking intelligently about. I am very happy I found this in my search for
    something relating to this.

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

  5. Magnificent beat ! I wish to apprentice while you amend your web
    site, how can i subscribe for a blog web site? The account
    aided me a acceptable deal. I had been tiny bit acquainted of this your broadcast provided bright
    clear concept

  6. I was curious if you ever considered 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 images.

    Maybe you could space it out better?

  7. Hello! I’ve been reading your web site for some time now and finally
    got the courage to go ahead and give you a shout out from
    Lubbock Tx! Just wanted to tell you keep up the excellent work!

  8. Aw, this was an incredibly nice post. Spending some time and actual effort to make a great article… but what can I say… I hesitate a whole lot and never manage to get nearly anything
    done.

  9. Hmm is anyone else experiencing problems with the pictures on this blog loading?
    I’m trying to determine if its a problem on my end or if it’s the blog.
    Any responses would be greatly appreciated.

  10. Greetings! I’ve been following your web site for a long time now and finally got the bravery to
    go ahead and give you a shout out from Huffman Texas!
    Just wanted to mention keep up the good work!

  11. Howdy just wanted to give you a quick heads up.
    The text in your article seem to be running off the
    screen in Chrome. I’m not sure if this is a formatting issue or something to do with web browser compatibility but I figured I’d post to let you know.

    The design and style look great though! Hope you get the issue fixed soon. Kudos

  12. Having read this I thought it was very informative. I appreciate you taking the time
    and energy to put this article together.
    I once again find myself personally spending a significant amount of time both reading and leaving comments.
    But so what, it was still worth it!

  13. Hi there just wanted to give you a quick heads up.
    The words in your post seem to be running off the screen in Safari.

    I’m not sure if this is a formatting issue or something to do with browser compatibility but
    I figured I’d post to let you know. The design look great though!
    Hope you get the problem solved soon. Cheers

  14. Excellent blog here! Also your site loads up very fast!

    What 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

  15. After I initially left a comment I seem to have clicked the -Notify me when new comments are added- checkbox and
    from now on every time a comment is added I receive 4
    emails with the exact same comment. There has to be an easy method you can remove me
    from that service? Appreciate it!

  16. Greetings! This is my first visit to your blog! We are a group of volunteers and starting a new initiative in a community in the same niche.
    Your blog provided us useful information to work on. You have done a wonderful
    job!

Comments are closed.