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. whoah this blog is fantastic i love reading your posts. Stay up the great work!
    You realize, a lot of persons are searching round for this
    information, you could aid them greatly.

  2. I am extremely impressed together with your writing talents as
    well as with the format for your blog. Is that this a paid subject matter or did you modify it yourself?
    Anyway stay up the nice high quality writing, it’s rare to see a great blog like this one these days..

  3. What’s Taking place i’m new to this, I stumbled upon this I have discovered It absolutely
    helpful and it has aided me out loads. I hope to contribute & aid different users
    like its helped me. Good job.

  4. Hello fantastic blog! Does running a blog such
    as this take a great deal of work? I’ve very little understanding of computer programming however I was hoping to start my
    own blog soon. Anyway, should you have any suggestions or techniques for new blog
    owners please share. I know this is off subject nevertheless I simply wanted to ask.
    Kudos!

  5. Hello there! I could have sworn I’ve been to this site before but after reading through some of the post I realized it’s
    new to me. Anyhow, I’m definitely delighted I found it and
    I’ll be book-marking and checking back frequently!

  6. I’m gone to inform my little brother, that he should also go to see this web site on regular basis to
    obtain updated from latest news update.

  7. I am extremely impressed with your writing skills and also with the layout on your weblog.
    Is this a paid theme or did you customize it yourself?
    Anyway keep up the nice quality writing, it
    is rare to see a great blog like this one these days.

  8. This piece of writing will help the internet people
    for creating new web site or even a weblog from start
    to end.

  9. I’m not sure exactly why but this blog is loading extremely slow for me.
    Is anyone else having this issue or is it a problem on my
    end? I’ll check back later and see if the problem still exists.

  10. Howdy! I realize this is sort of off-topic
    but I had to ask. Does managing a well-established blog such
    as yours require a lot of work? I’m completely new to writing a blog however I do write in my journal every day.
    I’d like to start a blog so I can easily share my personal experience and thoughts online.
    Please let me know if you have any suggestions or tips for
    brand new aspiring bloggers. Appreciate it!

  11. Wow that was strange. I just wrote an very long comment but after I clicked submit my
    comment didn’t show up. Grrrr… well I’m not writing all that over
    again. Regardless, just wanted to say excellent blog!

Comments are closed.