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 for … in.

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

  1. Hello there! Do you use Twitter? I’d like to follow you if that would
    be ok. I’m absolutely enjoying your blog and look forward to new updates.

  2. If some one wants expert view on the topic of blogging afterward i recommend him/her to visit this webpage, Keep up the fastidious job.

  3. I’m not sure exactly why but this weblog is loading extremely slow
    for me. Is anyone else having this problem or is it a issue on my end?

    I’ll check back later on and see if the problem still exists.

  4. Having read this I believed it was very informative. I appreciate you spending some time and energy to put this information together.
    I once again find myself spending a lot of time both reading and leaving comments.
    But so what, it was still worthwhile!

  5. Its like you learn my thoughts! You appear to understand a lot
    approximately this, like you wrote the book in it or something.
    I think that you just could do with some p.c.
    to drive the message home a bit, however instead of that, that is excellent blog.
    A fantastic read. I’ll certainly be back.

  6. Today, I went to the beachfront 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 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 completely off topic but I had to tell someone!

  7. Link exchange is nothing else except it is only placing the other person’s blog
    link on your page at appropriate place and other person will also do same
    for you.

  8. Good day! Do you use Twitter? I’d like to follow you if that
    would be okay. I’m definitely enjoying your blog and look forward to new updates.

  9. Good day! I could have sworn I’ve visited this web site before but after going through some of the articles I realized it’s new to me.
    Anyhow, I’m certainly happy I discovered it and I’ll be book-marking it and checking back frequently!

  10. wonderful issues altogether, you just won a new
    reader. What might you suggest in regards to your post that you simply
    made some days in the past? Any sure?

  11. The other day, while I was at work, my sister stole my iphone and tested to see if it can survive a twenty five foot drop, just so she can be a
    youtube sensation. My iPad is now broken and she has 83 views.

    I know this is completely off topic but I had
    to share it with someone!

  12. I know this web site presents quality depending articles or reviews and other material, is
    there any other web page which presents such stuff in quality?

  13. I feel that is among the so much significant info for me.
    And i’m satisfied reading your article. But should
    statement on few basic things, The web site taste is
    great, the articles is actually excellent : D. Good process,
    cheers

  14. I relish, lead to I found exactly what I used to
    be taking a look for. You have ended my 4 day lengthy hunt!
    God Bless you man. Have a great day. Bye

Comments are closed.