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. Thanks for another magnificent post. The place else could
    anyone get that type of info in such a perfect manner of writing?
    I’ve a presentation subsequent week, and I’m on the search for such info.

  2. Do you have a spam problem on this blog; I also am a blogger,
    and I was curious about your situation; many of us have developed some nice
    procedures and we are looking to swap solutions with other folks, be
    sure to shoot me an email if interested.

  3. I do not even understand how I stopped up here, however I thought this publish was
    good. I don’t realize who you are but definitely you
    are going to a well-known blogger for those who are not already.

    Cheers!

  4. 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 Movable-type on a number of websites for about a year and am
    worried about switching to another platform. I have heard excellent
    things about blogengine.net. Is there a way I can import all my wordpress posts into it?
    Any help would be really appreciated!

  5. I always used to study piece of writing in news papers but now as I am a user of
    internet thus from now I am using net for
    articles or reviews, thanks to web.

  6. 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?
    Thanks!

  7. Hi there, just became aware of your blog through Google,
    and found that it’s really informative. I am going to watch out
    for brussels. I’ll be grateful if you continue
    this in future. Lots of people will be benefited from your writing.

    Cheers!

  8. Thanks for one’s marvelous posting! I certainly
    enjoyed reading it, you might be a great author.
    I will be sure to bookmark your blog and will often come back
    later in life. I want to encourage one to continue your great posts, have a nice weekend!

  9. Hi i am kavin, its my first occasion to commenting anywhere, when i read this piece of writing i thought
    i could also create comment due to this brilliant post.

  10. Excellent blog here! Also your website loads up very fast!
    What web host are you using? Can I get your affiliate link
    to your host? I wish my web site loaded up as quickly as
    yours lol

  11. Thanks for one’s marvelous posting! I truly enjoyed reading it, you will be a great author.I will always bookmark your blog and will come back down the road.
    I want to encourage you to continue your great work, have a nice afternoon!

  12. Thanks for sharing your thoughts. I really appreciate your efforts and
    I am waiting for your next write ups thank you once again.

  13. Great goods from you, man. I have understand your stuff previous to and you
    are just too great. I really like what you’ve acquired here, really
    like what you’re saying and the way in which you say it.
    You make it enjoyable and you still care for to keep it wise.
    I can’t wait to read much more from you. This is actually a great site.

  14. 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 are not already 😉 Cheers!

  15. Hey, I think your website might be having browser compatibility issues.
    When I look at your blog in Opera, it looks fine but when opening in Internet Explorer, it has some overlapping.
    I just wanted to give you a quick heads up!

    Other then that, excellent blog!

  16. First of all I want to say superb blog! I had a quick question in which
    I’d like to ask if you do not mind. I was interested to
    find out how you center yourself and clear your mind before writing.
    I’ve had a difficult time clearing my mind in getting my ideas out there.
    I truly do take pleasure in writing however it just seems
    like the first 10 to 15 minutes are lost just trying to figure out
    how to begin. Any recommendations or tips? Appreciate it!

  17. We’re a group of volunteers and opening a new scheme in our community.

    Your site offered us with valuable info to work on. You have done an impressive job and our whole community will be thankful to you.

  18. I’m curious to find out what blog platform you are utilizing?
    I’m experiencing some minor security problems with my latest website and I’d like to
    find something more secure. Do you have any suggestions?

  19. Have you ever considered 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 pics and clips, this website could definitely be one of the most beneficial in its niche.

    Superb blog!

  20. We 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 again.

  21. Thanks for a marvelous posting! I certainly
    enjoyed reading it, you will be a great author.I will make sure to bookmark your blog
    and definitely will come back someday. I want to encourage that you continue your great job, have a nice morning!

Comments are closed.