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. Have you ever thought about including a little bit more than just
    your articles? I mean, what you say is valuable and everything.
    But just imagine if you added some great images or videos
    to give your posts more, “pop”! Your content is excellent
    but with images and video clips, this blog could certainly
    be one of the most beneficial in its field.
    Amazing blog!

  2. I enjoy what you guys are up too. This kind of clever
    work and exposure! Keep up the excellent works guys I’ve included you guys to blogroll.

  3. I’m gone to inform my little brother, that he should also pay
    a visit this webpage on regular basis to take updated from most recent information.

  4. Hey there, You’ve done an excellent job. I will definitely digg it
    and personally suggest to my friends. I am sure they will be benefited from this web site.

  5. Wow that was strange. I just wrote an extremely long comment but
    after I clicked submit my comment didn’t appear. Grrrr…

    well I’m not writing all that over again. Anyway, just wanted to say great
    blog!

  6. obviously like your web site but you have to check the spelling on several of your posts.

    Several of them are rife with spelling issues and
    I in finding it very troublesome to inform the reality then again I’ll certainly come again again.

  7. Having read this I thought it was extremely enlightening.
    I appreciate you finding the time and effort to put this short article together.
    I once again find myself personally spending a lot of time both reading
    and leaving comments. But so what, it was still worth it!

  8. Its like you read my thoughts! You seem to know a lot approximately this, such as
    you wrote the e book in it or something. I think 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’ll definitely be
    back.

  9. Howdy 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
    internet browsers and both show the same results.

  10. When I initially commented I clicked the “Notify me when new comments are added” checkbox and now each time
    a comment is added I get several emails with
    the same comment. Is there any way you can remove people from
    that service? Appreciate it!

  11. Hello there! 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 tips?

  12. Good day! I could have sworn I’ve been to this blog 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 book-marking and checking back frequently!

  13. Incredible! This blog looks just like my old one!
    It’s on a totally different subject but it has pretty
    much the same page layout and design. Outstanding choice of colors!

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

  15. Attractive section 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 to your feeds and even I
    achievement you access consistently fast.

  16. Its such as you learn my thoughts! You appear to understand a lot approximately this, like you wrote
    the e-book in it or something. I feel that you just could
    do with a few % to power the message house a bit, but other than that, that is wonderful blog.
    An excellent read. I’ll certainly be back.

    Also visit my blog login poker online

Comments are closed.