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 the best time to make a few plans for the longer term and it is time to be happy.
    I have learn this put up and if I may I want to recommend you
    few interesting issues or advice. Maybe you could write next articles regarding
    this article. I want to learn more issues approximately it!

  2. Wow that was odd. I just wrote an very long comment but after I
    clicked submit my comment didn’t appear. Grrrr… well I’m not writing all that over again. Anyways, just wanted to say fantastic blog!

  3. My relatives every time say that I am killing my time here at
    net, but I know I am getting know-how all the time by reading
    thes good articles or reviews.

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

  5. It is the best time to make some plans for the longer term
    and it is time to be happy. I have read this put up and if I could I want to recommend you some
    attention-grabbing issues or suggestions. Maybe you could write subsequent articles regarding this article.
    I want to learn even more issues about it!

  6. Pretty nice post. I just stumbled upon your
    blog and wanted to say that I have truly enjoyed surfing around your
    blog posts. In any case I’ll be subscribing to
    your feed and I hope you write again soon!

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

  8. A motivating discussion is worth comment. I do believe that you need to write
    more on this subject matter, it might not be a taboo subject but
    generally people don’t talk about such topics. To the next!
    Cheers!!

  9. Write more, thats all I have to say. Literally,
    it seems as though you relied on the video to
    make your point. You definitely know what youre talking about, why throw away your
    intelligence on just posting videos to your site when you could be giving
    us something enlightening to read?

  10. I’m extremely impressed with your writing skills and also
    with the layout on your blog. Is this a paid theme or did you customize it yourself?
    Anyway keep up the excellent quality writing, it’s rare to see a nice blog like this one
    these days.

  11. This is very interesting, You are a very skilled blogger.

    I have joined your rss feed and look forward to seeking more of your wonderful post.
    Also, I’ve shared your site in my social networks!

  12. Hello! I’m at work browsing your blog from my new iphone 4!
    Just wanted to say I love reading through your blog
    and look forward to all your posts! Carry on the excellent work!

  13. The other day, while I was at work, my cousin stole my iPad and tested to see if
    it can survive a thirty foot drop, just so she can be a youtube sensation. My apple ipad is now broken and
    she has 83 views. I know this is completely off topic but I had to share it with someone!

  14. It’s a pity you don’t have a donate button! I’d most certainly donate
    to this brilliant blog! I guess for now i’ll settle for book-marking and adding your RSS feed to my Google account.
    I look forward to fresh updates and will talk about this blog with my Facebook group.
    Talk soon!

  15. Hi there! I know this is kinda off topic nevertheless I’d figured I’d ask.
    Would you be interested in exchanging links or maybe guest writing
    a blog post or vice-versa? My blog addresses a lot of
    the same subjects as yours and I feel we could greatly benefit from each other.
    If you’re interested feel free to send me an e-mail. I look forward to
    hearing from you! Fantastic blog by the way!

    My web site … main slot

  16. Greetings! 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 beneficial information to work
    on. You have done a outstanding job!

    Here is my webpage :: slot pg soft gratis

  17. hello!,I like your writing so a lot! share we communicate extra about
    your article on AOL? I need an expert on this space to unravel my problem.
    Maybe that is you! Taking a look forward to see you.

  18. Hi just wanted to give you a brief 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.

  19. Hi there just wanted to give you a quick heads up.
    The text in your article seem to be running off the screen in Chrome.
    I’m not sure if this is a format issue or something to do with internet browser compatibility but I figured
    I’d post to let you know. The design look great though!
    Hope you get the problem fixed soon. Kudos

  20. It’s a pity you don’t have a donate button! I’d most certainly donate to this superb blog!
    I guess for now i’ll settle for book-marking and adding
    your RSS feed to my Google account. I look forward to
    brand new updates and will talk about this site with my Facebook
    group. Chat soon!

  21. Asking questions are actually fastidious thing if you are not understanding anything completely,
    except this post gives fastidious understanding yet.

  22. Having read this I thought it was extremely enlightening.
    I appreciate you taking the time and effort to put this content together.
    I once again find myself personally spending a significant amount of time both reading and posting comments.
    But so what, it was still worthwhile!

  23. Very good blog! Do you have any recommendations 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 options out there
    that I’m totally confused .. Any suggestions? Kudos!

Comments are closed.