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. I’m amazed, I must say. Rarely do I come across
    a blog that’s both educative and entertaining,
    and without a doubt, you have hit the nail on the head. The problem is an issue
    that not enough folks are speaking intelligently about.
    Now i’m very happy I found this during my search for something regarding this.

  2. We stumbled over here different web page and thought I
    should check things out. I like what I see so now i’m
    following you. Look forward to checking out your web page again.

  3. Greetings! I’ve been following your web site for some time now and finally got
    the courage to go ahead and give you a shout out from
    Huffman Texas! Just wanted to say keep up the fantastic job!

  4. The other day, while I was at work, my sister stole my apple ipad and
    tested to see if it can survive a forty foot drop, just so she can be a youtube sensation. My iPad is now destroyed and she has 83 views.
    I know this is entirely off topic but I had to share it with someone!

  5. Great weblog right here! Additionally your web
    site rather a lot up fast! What host are you the use of?
    Can I get your associate link for your host?
    I want my site loaded up as fast as yours lol

  6. 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 a few pics to drive the message home a bit, but
    instead of that, this is magnificent blog. A great read. I will definitely be back.

  7. You should take part in a contest for one of the highest quality sites on the web.

    I most certainly will highly recommend this web site!

  8. Hi! I just wanted to ask if you ever have any problems with hackers?
    My last blog (wordpress) was hacked and I ended up losing months of hard work due to no backup.
    Do you have any solutions to stop hackers?

  9. I loved as much as you will receive carried out right
    here. The sketch is tasteful, your authored subject matter stylish.
    nonetheless, you command get bought an shakiness over that you wish be delivering
    the following. unwell unquestionably come more formerly again since exactly the same nearly a
    lot often inside case you shield this hike.

  10. Have you ever considered about including a little bit more than just your articles?
    I mean, what you say is fundamental and everything.
    But imagine if you added some great visuals or video clips to
    give your posts more, “pop”! Your content is excellent but with images and clips, this blog could undeniably
    be one of the very best in its niche. Superb blog!

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

  12. Appreciating the dedication you put into your blog and detailed
    information you offer. It’s great to come across a blog every once in a while that
    isn’t the same out of date rehashed information. Wonderful read!
    I’ve saved your site and I’m including your RSS feeds to
    my Google account.

  13. Today, I went to the beach with my kids. 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 put 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!

  14. My spouse and I stumbled over here different web address
    and thought I should check things out. I like what I see so now i am following you.
    Look forward to exploring your web page yet again.

  15. Attractive component to content. I just stumbled upon your weblog and
    in accession capital to say that I acquire in fact loved account your weblog posts.
    Anyway I’ll be subscribing in your feeds or even I fulfillment you get entry to constantly fast.

  16. What i do not understood is actually how you are no longer actually much more well-liked than you might be now.
    You are very intelligent. You already know thus significantly
    on the subject of this subject, made me individually consider it from so many varied angles.
    Its like men and women are not fascinated except it’s one
    thing to do with Girl gaga! Your personal stuffs nice.
    At all times take care of it up!

  17. you are truly a excellent webmaster. The site loading speed is incredible.
    It seems that you are doing any unique trick. Moreover, The contents are masterwork.
    you have performed a great activity on this subject!

Comments are closed.