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. You can certainly see your skills within the article you write.
    The world hopes for even more passionate writers like you who
    are not afraid to mention how they believe. At all times go
    after your heart.

  2. I’m extremely impressed with your writing skills and also with the layout on your weblog.

    Is this a paid theme or did you modify it yourself?

    Either way keep up the nice quality writing, it’s rare to
    see a nice blog like this one today.

  3. I love what you guys tend to be up too. This kind of clever work and coverage!
    Keep up the fantastic works guys I’ve incorporated you guys to
    blogroll.

  4. 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
    completely off topic but I had to tell someone!

  5. I don’t even understand how I ended up here, but I believed this put up was great.
    I do not understand who you’re but definitely you’re going to
    a famous blogger in the event you aren’t already. Cheers!

  6. Wow, wonderful weblog structure! How lengthy have you been running a blog for?
    you make blogging glance easy. The full look of your site
    is great, as neatly as the content material!

  7. Heya i’m for the primary time here. I came across this board and I find It truly useful
    & it helped me out much. I am hoping to give one thing again and help others
    like you helped me.

  8. Very great post. I simply stumbled upon your blog and wished to say that I have truly enjoyed browsing your weblog posts.
    In any case I will be subscribing to your feed and I am hoping you write again soon!

  9. Hello just wanted to give you a quick heads up and let you know a few of the pictures
    aren’t loading properly. I’m not sure why but I
    think its a linking issue. I’ve tried it in two different browsers
    and both show the same results.

  10. I do not even know how I ended up here, but I thought this
    post was good. I don’t know who you are but definitely you are going to a
    famous blogger if you aren’t already 😉 Cheers!

  11. Hello there! I could have sworn I’ve visited this blog before but
    after going through many of the posts I realized it’s new to me.
    Nonetheless, I’m definitely pleased I found it and I’ll be bookmarking it and checking
    back often!

  12. I don’t even know how I ended up here, but I thought this post was great.
    I don’t know who you are but certainly you are going to a famous blogger if you are
    not already 😉 Cheers!

  13. My partner and I stumbled over here coming from a different page and
    thought I might check things out. I like what I see so i am just following you.
    Look forward to finding out about your web page for a second time.

  14. Hi! Someone in my Myspace group shared this site with us so I came to look it over.
    I’m definitely loving the information. I’m bookmarking and will be tweeting
    this to my followers! Terrific blog and fantastic style and design.

  15. Hey there just wanted to give you a quick heads up.
    The text in your article seem to be running off the screen in Safari.
    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 layout look great though!

    Hope you get the issue resolved soon. Kudos

  16. Heya! I’m at work surfing around your blog from my new apple iphone!
    Just wanted to say I love reading through your blog and look forward to all your posts!
    Carry on the fantastic work!

  17. I have been exploring for a bit for any high-quality
    articles or blog posts on this sort of space . Exploring in Yahoo I eventually stumbled upon this site.
    Studying this info So i’m satisfied to convey that I have an incredibly just right uncanny feeling I found out exactly what I needed.
    I so much no doubt will make certain to don?t overlook this web site and give it
    a glance regularly.

  18. Its like you read my mind! You appear to know so much about this, like
    you wrote the book in it or something. I think that
    you could do with some pics to drive the message home a bit,
    but other than that, this is great blog. A great read.
    I’ll certainly be back.

  19. I don’t even know how I ended up here, but I thought this post was great.
    I don’t know who you are but certainly you are going to a famous blogger if you are not already 😉
    Cheers!

  20. Hi! I’ve been following your site for a while now and finally got the courage
    to go ahead and give you a shout out from Houston Tx!
    Just wanted to say keep up the good job!

Comments are closed.