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. It’s amazing to pay a quick visit this site
    and reading the views of all colleagues regarding this piece of writing, while I am also zealous of getting know-how.

  2. It’s appropriate time to make a few plans for the long run and it is time to be happy.

    I have learn this submit and if I may I want to
    counsel you few fascinating issues or suggestions. Perhaps you can write next articles relating to this article.
    I desire to learn more issues approximately it!

  3. Yesterday, while I was at work, my cousin stole my apple ipad and tested
    to see if it can survive a twenty five foot drop, just so she can be a youtube
    sensation. My 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. Right here is the perfect webpage for anybody who wishes
    to understand this topic. You know so much its almost hard to argue with you (not that I
    personally would want to…HaHa). You certainly put a new spin on a subject that’s been discussed for many
    years. Wonderful stuff, just excellent!

  5. Fantastic items from you, man. I’ve take note
    your stuff previous to and you are just extremely great.
    I actually like what you have acquired here,
    certainly like what you’re saying and the way by which you say it.
    You’re making it enjoyable and you continue to care for to
    stay it wise. I can not wait to read far more from you.

    That is actually a terrific site.

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

    You realize a whole lot its almost hard to argue with you
    (not that I actually will need to…HaHa). You definitely put a brand new spin on a topic which has been written about
    for decades. Great stuff, just excellent!

  7. Hi everyone, it’s my first pay a quick visit at this web site, and article is actually fruitful in support of
    me, keep up posting these types of articles or reviews.

  8. Have you ever considered creating an e-book or guest authoring on other sites?
    I have a blog based on the same subjects you discuss and
    would love to have you share some stories/information. I know my audience would appreciate your work.
    If you’re even remotely interested, feel free to send
    me an e mail.

  9. Fantastic blog! Do you have any tips for aspiring writers?

    I’m planning to start my own site soon but I’m a
    little lost on everything. Would you propose starting with a free
    platform like WordPress or go for a paid option? There are so many choices out there
    that I’m totally confused .. Any recommendations? Cheers!

  10. Hello everyone, it’s my first pay a visit at this web site, and paragraph is in fact fruitful in favor of me, keep up
    posting these content.

  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 can do with a few pics to drive the
    message home a little bit, but other than that, this is wonderful blog.

    A great read. I will definitely be back.

  12. Hello would you mind letting me know which webhost you’re working with?
    I’ve loaded your blog in 3 completely different web browsers and I must
    say this blog loads a lot faster then most. Can you recommend a
    good internet hosting provider at a honest price? Kudos,
    I appreciate it!

  13. Someone necessarily help to make critically articles I’d state.
    That is the very first time I frequented your web
    page and to this point? I surprised with the research you made to make this particular put up incredible.
    Wonderful task!

  14. You can certainly see your skills in the work you
    write. The world hopes for even more passionate writers such as you who are not afraid to say how they
    believe. At all times go after your heart.

  15. It’s perfect time to make some plans for the long run and it is time to be happy.

    I’ve read this submit and if I could I wish to recommend you some attention-grabbing things or suggestions.
    Perhaps you could write subsequent articles relating to this article.
    I wish to read more issues approximately it!

  16. Hmm it looks like your blog ate my first comment (it was extremely long) so I guess I’ll just sum it up what I submitted 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 helpful hints for newbie blog
    writers? I’d definitely appreciate it.

  17. Hey! Someone in my Facebook group shared this site with us
    so I came to check it out. I’m definitely loving the information. I’m book-marking and will be tweeting this to my followers!

    Superb blog and excellent design.

Comments are closed.