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

  1. Hey there! I’ve been following your blog for a long time now and finally got the
    courage to go ahead and give you a shout out from New Caney Texas!
    Just wanted to tell you keep up the excellent job!

  2. Have you ever considered publishing an ebook or guest authoring on other sites?
    I have a blog based upon on the same information you discuss
    and would love to have you share some stories/information. I know my visitors would value your work.

    If you are even remotely interested, feel free
    to send me an e mail.

  3. I like the helpful info you supply for your articles.
    I’ll bookmark your blog and take a look at again right here
    regularly. I’m relatively sure I’ll be told lots of new stuff proper right here!
    Best of luck for the following!

  4. Having read this I believed it was extremely informative.

    I appreciate you spending some time and effort to put this
    short article together. I once again find myself spending
    way too much time both reading and commenting.
    But so what, it was still worth it!

  5. Hmm it seems like your blog 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 blogger but I’m still
    new to the whole thing. Do you have any suggestions for rookie blog writers?
    I’d definitely appreciate it.

  6. Have you ever considered about including
    a little bit more than just your articles?
    I mean, what you say is valuable and all.
    However think about if you added some great images or video clips to give your posts more, “pop”!
    Your content is excellent but with pics and videos, this blog could
    undeniably be one of the most beneficial in its
    field. Very good blog!

  7. Hi there, i read your blog from time to time and i own a similar one and i
    was just curious if you get a lot of spam comments?
    If so how do you reduce it, any plugin or anything
    you can recommend? I get so much lately it’s driving me
    insane so any assistance is very much appreciated.

  8. I’ve been browsing on-line more than 3 hours lately, but I
    by no means discovered any attention-grabbing article like yours.
    It’s lovely value enough for me. Personally, if all site
    owners and bloggers made excellent content as you probably
    did, the internet will be a lot more helpful than ever before.

  9. Today, I went to the beach with my children. I found a sea shell and gave
    it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She placed the shell to her ear and screamed.
    There was a hermit crab inside and it pinched her ear. She never wants to go back!
    LoL I know this is entirely off topic but I had to tell someone!

  10. If some one needs to be updated with newest technologies therefore
    he must be pay a quick visit this web page
    and be up to date everyday.

  11. Hey! I just wanted to ask if you ever have any problems with hackers?
    My last blog (wordpress) was hacked and I ended up losing a few months of
    hard work due to no data backup. Do you have any methods to prevent hackers?

  12. When I originally commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment
    is added I get four emails with the same comment.
    Is there any way you can remove people from that service?

    Appreciate it!

  13. Admiring the hard work you put into your site
    and in depth information you provide. It’s good to come across a blog
    every once in a while that isn’t the same old rehashed information. Excellent read!

    I’ve saved your site and I’m adding your RSS feeds to
    my Google account.

  14. What i do not realize is in fact how you are now not actually
    a lot more neatly-preferred than you may be right now. You are so intelligent.

    You recognize thus significantly relating to this subject, made me for my part believe
    it from a lot of numerous angles. Its like men and women don’t seem to be interested until it
    is something to do with Woman gaga! Your personal stuffs
    outstanding. At all times care for it up!

  15. When I originally commented I appear to have clicked the -Notify me when new comments are
    added- checkbox and from now on whenever a comment is added
    I recieve 4 emails with the same comment. There has to be a means you are
    able to remove me from that service? Cheers!

  16. Hello, i read your blog occasionally and i own a similar one and i
    was just curious if you get a lot of spam
    comments? If so how do you protect against it, any plugin or anything you can recommend?
    I get so much lately it’s driving me mad so any help is very
    much appreciated.

  17. I’m curious to find out what blog platform you
    are working with? I’m having some small security problems with my latest blog and
    I would like to find something more safeguarded. Do you have any solutions?

Comments are closed.