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 mates, how is all, and what you desire to say about
    this piece of writing, in my view its truly amazing designed for me.

  2. Have you ever thought about including a little bit more
    than just your articles? I mean, what you say is important and all.
    But think about if you added some great photos or videos to give your posts more, “pop”!
    Your content is excellent but with images and videos, this site could definitely be one of
    the most beneficial in its niche. Good blog!

  3. This is very interesting, You’re a very skilled
    blogger. I’ve joined your rss feed and look forward to seeking more of your wonderful post.
    Also, I’ve shared your web site in my social networks!

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

  5. An interesting discussion is definitely worth comment.

    I think that you should write more about this topic, it may not be a taboo subject but generally folks don’t talk about such subjects.
    To the next! Kind regards!!

  6. Howdy! 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.
    Anyways, I’m definitely glad I found it and I’ll be bookmarking and checking
    back frequently!

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

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

  9. It’s in fact very complicated in this active life to listen news on Television, so I only use web for that purpose, and take the newest information.

  10. Appreciating the persistence you put into your site and detailed information you offer.
    It’s great to come across a blog every once in a while that
    isn’t the same out of date rehashed information. Fantastic read!
    I’ve saved your site and I’m adding your RSS feeds to my Google account.

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

  12. Whats up 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
    experience so I wanted to get guidance from someone with experience.
    Any help would be enormously appreciated!

  13. I just like the valuable info you supply on your articles.
    I’ll bookmark your weblog and take a look at once more here
    frequently. I’m slightly certain I will be informed lots of new
    stuff proper right here! Good luck for the next!

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

  15. Its such as you read my mind! You appear to know a lot about this, like
    you wrote the e book in it or something. I think that you could do
    with a few percent to drive the message home a bit, but instead of that, that is excellent blog.

    An excellent read. I will definitely be back.

  16. My spouse and I stumbled over here 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 going over your web page repeatedly.

  17. each time i used to read smaller posts which as well clear their motive,
    and that is also happening with this piece of
    writing which I am reading at this place.

  18. Hi there! I just wanted to ask if you ever have any problems with hackers?
    My last blog (wordpress) was hacked and I ended
    up losing a few months of hard work due to no backup.
    Do you have any solutions to prevent hackers?

  19. Attractive element of content. I just stumbled upon your web
    site and in accession capital to assert that I get actually enjoyed account your
    blog posts. Anyway I’ll be subscribing on your feeds or even I fulfillment you get
    right of entry to consistently rapidly.

  20. Heya 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!

  21. Right now it appears like Drupal is the top
    blogging platform out there right now. (from what I’ve read) Is
    that what you’re using on your blog?

  22. What i do not realize is in reality how you are not actually
    much more well-favored than you may be now. You
    are very intelligent. You know thus significantly relating to this matter,
    made me in my opinion believe it from a lot of numerous
    angles. Its like men and women are not interested until it is one thing to accomplish with Woman gaga!
    Your individual stuffs nice. All the time deal with it up!

  23. I have been surfing on-line greater than 3 hours
    these days, but I never discovered any attention-grabbing article like yours.
    It’s beautiful value sufficient for me. In my view, if all site owners and bloggers made
    just right content material as you probably did, the net will probably be much more helpful than ever
    before.

  24. Hello colleagues, how is the whole thing, and what you would like to say on the topic of this piece of writing,
    in my view its truly amazing designed for me.

Comments are closed.