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. Hello there! 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 valuable
    information to work on. You have done a marvellous job!

  2. A fascinating discussion is definitely worth comment.
    There’s no doubt that that you need to publish more on this issue, it may not
    be a taboo subject but generally folks don’t talk about these issues.

    To the next! All the best!!

  3. We’re a gaggle of volunteers and starting a new scheme in our community.
    Your web site provided us with helpful info to work on.
    You’ve performed an impressive process and our whole group can be grateful to you.

  4. Wow! This blog looks exactly like my old one! It’s on a entirely different topic
    but it has pretty much the same layout and design. Outstanding choice of colors!

  5. Hello there! I know this is kinda off topic but I’d figured I’d ask.
    Would you be interested in exchanging links or maybe guest authoring a
    blog article or vice-versa? My site goes over a lot of the same topics as yours and
    I believe we could greatly benefit from each other.
    If you might be interested feel free to shoot me an email.
    I look forward to hearing from you! Superb blog by the way!

  6. 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.

  7. 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.

  8. 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.

  9. 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!

  10. 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.

  11. 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!

  12. 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.

  13. 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.

  14. 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!

  15. 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?

Comments are closed.