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.

48,210 thoughts on “Contoh Soal Pemrograman – Pola Segitiga Siku-siku

  1. Aw, this was an incredibly nice post. Taking
    a few minutes and actual effort to generate a very good article… but what can I say… I hesitate a
    whole lot and don’t manage to get anything
    done.

  2. My brother suggested I might like this website.
    He was entirely right. This post truly made my day. You can not imagine just how much time I
    had spent for this information! Thanks!

  3. Today, I went to the beach 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!

  4. obviously like your web-site but you have to check the spelling on several of your posts.
    Several of them are rife with spelling issues and I to find it very troublesome to tell the truth then again I will definitely come back
    again.

  5. First off I would like to say fantastic blog!
    I had a quick question in which I’d like to ask if you don’t mind.

    I was interested to know how you center yourself and
    clear your thoughts prior to writing. I’ve had a tough time clearing
    my mind in getting my thoughts out there. I truly do take pleasure in writing
    but it just seems like the first 10 to 15 minutes are usually wasted just trying to figure out how to begin. Any suggestions or tips?
    Cheers!

  6. I like the valuable info you provide in your articles.
    I’ll bookmark your blog and check again here frequently.
    I am quite sure I’ll learn lots of new stuff right here! Best of luck
    for the next!

  7. I think this is among the most significant info for me.
    And i am glad reading your article. But wanna remark on few general things, The website
    style is wonderful, the articles is really great : D.
    Good job, cheers

  8. Hey there! I’ve been following your site for a long time now and finally got
    the courage to go ahead and give you a shout out from New Caney Texas!
    Just wanted to mention keep up the great work!

  9. My coder is trying to persuade me to move to .net from PHP.

    I have always disliked the idea because of the costs.
    But he’s tryiong none the less. I’ve been using WordPress on a variety of websites for about a year and am worried about switching to another platform.
    I have heard good things about blogengine.net. Is there
    a way I can import all my wordpress content into it? Any kind of help would be greatly appreciated!

  10. Just wish to say your article is as astonishing. The clarity
    in your post is simply spectacular and i can assume you’re an expert on this subject.
    Well with your permission allow me to grab your RSS feed to keep up to date with forthcoming post.
    Thanks a million and please continue the rewarding
    work.

  11. I’m amazed, I have to admit. Seldom do I come across a blog that’s
    equally educative and entertaining, and let me tell you, you have
    hit the nail on the head. The problem is an issue that too few people are speaking
    intelligently about. Now i’m very happy that I came across this during my hunt for something relating to this.

  12. Today, I went to the beach 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!

  13. Heya i’m for the first time here. I came across this
    board and I in finding It truly helpful & it
    helped me out much. I am hoping to give something back and help others like you helped me.

  14. Hello my loved one! I want to say that this post is amazing,
    nice written and come with approximately all vital infos. I’d like to see extra posts like this .

  15. Thanks for any other informative website.

    The place else could I am getting that kind of info written in such a perfect method?
    I have a mission that I’m simply now operating on, and I have been at the glance out for such information.

  16. I like the helpful info you supply in your articles.
    I’ll bookmark your weblog and check again right here frequently.
    I’m moderately sure I’ll be told many new stuff right here!

    Best of luck for the next!

  17. I was excited to discover this page. I want to to thank you for ones time due to this
    wonderful read!! I definitely appreciated
    every bit of it and i also have you book-marked to see new information on your website.

  18. Woah! I’m really digging the template/theme of
    this website. It’s simple, yet effective. A lot of times it’s tough to get
    that “perfect balance” between user friendliness and appearance.
    I must say that you’ve done a superb job with this. Also, the blog loads extremely fast for me on Safari.

    Superb Blog!

  19. When I originally commented I clicked the “Notify me when new comments are added” checkbox and now
    each time a comment is added I get several e-mails with the same comment.
    Is there any way you can remove people from that service?

    Thank you!

  20. This is really interesting, You are a very skilled blogger.
    I have joined your feed and look forward to seeking more of your great post.
    Also, I’ve shared your web site in my social networks!

  21. Admiring the commitment you put into your website and detailed information you present.
    It’s awesome to come across a blog every once in a while that isn’t the same out
    of date rehashed information. Wonderful read! I’ve saved your site and I’m adding your RSS feeds to my Google account.

  22. Hey There. I found your blog the use of msn. This
    is an extremely well written article. I will make sure to bookmark
    it and come back to learn extra of your useful info.
    Thank you for the post. I will definitely return.

  23. Hi! I could have sworn I’ve been to this website before
    but after looking at many of the articles I realized it’s new to me.
    Anyhow, I’m definitely pleased I found it and I’ll
    be book-marking it and checking back often!

  24. I like what you guys tend to be up too. This type
    of clever work and coverage! Keep up the amazing works guys I’ve included you
    guys to blogroll.

Comments are closed.