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,249 thoughts on “Contoh Soal Pemrograman – Pola Segitiga Siku-siku

  1. Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point.
    You obviously know what youre talking about, why waste
    your intelligence on just posting videos to your blog when you could
    be giving us something informative to read?

  2. Aw, this was an incredibly nice post. Finding the time and actual effort to create a top notch article… but what can I say… I put things off a whole lot and never
    manage to get nearly anything done.

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

  4. Hmm it seems like your site ate my first comment (it
    was super long) so I guess I’ll just sum it up what I wrote and say, I’m thoroughly enjoying your blog.
    I too am an aspiring blog blogger but I’m still new to everything.
    Do you have any recommendations for newbie blog writers? I’d
    definitely appreciate it.

  5. Good day! I know this is kinda off topic but 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 goes over a lot of the same topics as yours and I think we could greatly benefit from each other.
    If you’re interested feel free to shoot me an e-mail. I look forward to
    hearing from you! Superb blog by the way!

  6. Its like you read my thoughts! You appear to understand so much about this, like you wrote the e book in it or something.
    I believe that you simply can do with some percent to drive the message home
    a bit, but other than that, that is fantastic blog. A great read.

    I will definitely be back.

  7. Hey, I think your blog might be having browser compatibility
    issues. When I look at your blog site in Chrome, 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!

  8. Its like you read my mind! You appear to know so much 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 bit, but instead of that, this is fantastic blog.
    An excellent read. I will definitely be back.

  9. Does your site have a contact page? I’m having a tough time locating it but, I’d
    like to send you an e-mail. I’ve got some recommendations for
    your blog you might be interested in hearing. Either way, great site and I look
    forward to seeing it expand over time.

  10. It’s actually very complex in this full of
    activity life to listen news on Television, thus I just use the web for that reason,
    and get the hottest news.

  11. I have been surfing on-line more than three hours as of late, yet I never found any fascinating article like yours.

    It is pretty worth sufficient for me. Personally, if all site owners and bloggers made good content as you
    did, the net shall be much more useful than ever before.

  12. Howdy! Do you know if they make any plugins to safeguard against hackers?
    I’m kinda paranoid about losing everything I’ve worked hard on. Any recommendations?

  13. Does your site have a contact page? I’m having problems locating
    it but, I’d like to send you an email. I’ve got some recommendations for your blog
    you might be interested in hearing. Either way, great site and I
    look forward to seeing it develop over time.

  14. I love what you guys are up too. This type of clever work and coverage!
    Keep up the terrific works guys I’ve included you guys to my own blogroll.

  15. Howdy! Do you know if they make any plugins to help with Search Engine Optimization? I’m trying to
    get my blog to rank for some targeted keywords but I’m
    not seeing very good success. If you know of any please share.
    Cheers!

  16. 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
    waste your intelligence on just posting videos to
    your site when you could be giving us something enlightening
    to read?

  17. Hey there would you mind letting me know which web host you’re working with?
    I’ve loaded your blog in 3 different internet browsers and
    I must say this blog loads a lot quicker then most.

    Can you recommend a good hosting provider at a fair
    price? Cheers, I appreciate it!

  18. I am curious to find out what blog platform
    you’re working with? I’m having some minor security issues with my latest site
    and I’d like to find something more safe.
    Do you have any suggestions?

Comments are closed.