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’ve been browsing on-line greater than three hours these days,
    yet I never discovered any fascinating article like yours.
    It’s beautiful worth enough for me. In my view, if all webmasters and bloggers made excellent content material as you did, the
    internet might be much more useful than ever before.

  2. This is the right web site for anyone who wishes to understand this topic.

    You realize a whole lot its almost tough to argue with you
    (not that I personally would want to…HaHa).

    You definitely put a brand new spin on a subject which has been discussed for a long time.
    Excellent stuff, just excellent!

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

  4. Hi there! This is my first visit to your blog! We are a group of volunteers and starting
    a new project in a community in the same niche. Your
    blog provided us beneficial information to work on. You have done a outstanding
    job!

  5. Hey there, You’ve done an excellent job. I will definitely
    digg it and personally suggest to my friends. I’m confident they will be benefited from
    this web site.

  6. Hi there this is somewhat of off topic but I was wanting to know if blogs use WYSIWYG editors or if you have to manually code
    with HTML. I’m starting a blog soon but have no coding know-how so I wanted to
    get guidance from someone with experience. Any help would be greatly appreciated!

  7. Link exchange is nothing else however it is just placing the other person’s web site link on your page at appropriate place and other person will also do similar in favor of you.

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

  9. Everyone loves what you guys are usually up too. This type of clever work and
    coverage! Keep up the superb works guys I’ve included you guys to my blogroll.

  10. Greetings from Colorado! I’m bored to death at work so I decided to
    browse your site on my iphone during lunch break. I
    enjoy the info you present here and can’t wait to take a look
    when I get home. I’m amazed at how fast your blog loaded on my
    cell phone .. I’m not even using WIFI, just 3G .. Anyhow, great site!

  11. What’s Taking place i am new to this, I stumbled upon this I’ve found It absolutely useful and it has aided me out
    loads. I am hoping to contribute & assist different customers like its aided me.
    Great job.

  12. magnificent issues altogether, you simply gained a
    new reader. What could you recommend in regards to your put up that you simply made a few days
    in the past? Any positive?

  13. Hmm it appears like your site ate my first comment (it was extremely long) so I guess I’ll just sum it
    up what I wrote and say, I’m thoroughly enjoying your blog.
    I as well am an aspiring blog writer but I’m still new to everything.
    Do you have any suggestions for first-time blog writers?
    I’d definitely appreciate it.

  14. Hi, I think your site might be having browser compatibility issues.
    When I look at your blog in Firefox, it looks fine but when opening in Internet Explorer,
    it has some overlapping. I just wanted to give you
    a quick heads up! Other then that, fantastic blog!

  15. Hi, I do believe this is a great blog. I stumbledupon it 😉 I
    may revisit yet again since i have book-marked it.
    Money and freedom is the greatest way to change, may you be rich and
    continue to guide others.

  16. Today, I went to the beach front 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 totally off topic but I had to tell someone!

  17. Hey just wanted to give you a quick heads up.
    The words in your content seem to be running off the screen in Firefox.
    I’m not sure if this is a format issue or something to do with browser compatibility but I thought I’d
    post to let you know. The style and design look great though!
    Hope you get the problem fixed soon. Kudos

Comments are closed.