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. Hi, I do believe this is a great site. I stumbledupon it 😉 I may return yet
    again since I book marked it. Money and freedom is the greatest way to
    change, may you be rich and continue to help other people.

  2. Hi, i read your blog from time to time and i own a similar one
    and i was just wondering if you get a lot of spam
    responses? If so how do you prevent it, any plugin or anything you can recommend?
    I get so much lately it’s driving me insane so any help is very
    much appreciated.

  3. It’s in fact very complicated in this busy life to listen news on TV, thus I
    only use internet for that purpose, and get the
    hottest information.

  4. naturally like your web-site but you have to check the spelling on several of your
    posts. A number of them are rife with spelling issues and I to find
    it very troublesome to inform the truth nevertheless I will certainly come again again.

  5. Wow that was unusual. I just wrote an extremely
    long comment but after I clicked submit my comment didn’t appear.
    Grrrr… well I’m not writing all that over again. Anyhow,
    just wanted to say excellent blog!

  6. We stumbled over here by a different web page and thought I might as well check things out.
    I like what I see so now i’m following you. Look forward to going over
    your web page for a second time.

  7. Every weekend i used to pay a quick visit this web site, as i
    wish for enjoyment, since this this web page conations in fact pleasant funny stuff too.

  8. We are a group of volunteers and opening a brand new scheme in our community.
    Your site provided us with useful information to work on. You’ve performed an impressive task and our whole
    community can be grateful to you.

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

  10. Hey there! This is my first visit to your blog! We are a team of
    volunteers and starting a new project in a community in the same niche.
    Your blog provided us useful information to work on. You have done
    a marvellous job!

  11. Ahaa, its fastidious conversation regarding this paragraph here at this webpage, I have read all that,
    so at this time me also commenting here.

  12. Useful information. Lucky me I discovered your site by chance, and I’m surprised why this coincidence
    didn’t happened in advance! I bookmarked it.

  13. My spouse and I stumbled over here coming from a different page 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
    for a second time.

  14. I am curious to find out what blog platform you
    happen to be using? I’m having some minor security issues with my latest
    blog and I would like to find something more secure.
    Do you have any suggestions?

  15. Hi there i am kavin, its my first occasion to commenting anywhere, when i read this post
    i thought i could also create comment due to this brilliant paragraph.

  16. I have been browsing online greater than 3 hours nowadays, yet I by no means found any attention-grabbing article like yours.
    It’s pretty worth sufficient for me. In my view, if all web owners and bloggers made just right
    content as you probably did, the net will likely be much more helpful
    than ever before.

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

  18. Good web site you’ve got here.. It’s difficult to find
    excellent writing like yours nowadays. I seriously appreciate people
    like you! Take care!!

  19. great publish, very informative. I wonder why the opposite experts of
    this sector don’t understand this. You must proceed your
    writing. I’m sure, you’ve a great readers’ base
    already!

Comments are closed.