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. Hello! I just would like to give you a big thumbs up for
    your excellent information you have got here on this post.
    I will be coming back to your web site for more soon.

  2. Hey! 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?

  3. Today, I went to the beach front with my kids. I found
    a sea shell and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She placed the shell to her ear and screamed.

    There was a hermit crab inside and it pinched her ear. She never wants to
    go back! LoL I know this is totally off
    topic but I had to tell someone!

  4. What’s up, this weekend is fastidious in favor of me, as this
    moment i am reading this wonderful informative post here at my house.

  5. Hey there this is somewhat of off topic but I was wanting to know if blogs use
    WYSIWYG editors or if you have to manually code with HTML.
    I’m starting a blog soon but have no coding skills so I wanted
    to get advice from someone with experience.
    Any help would be enormously appreciated!

  6. Its such as you learn my mind! You seem to know a lot
    approximately this, like you wrote the book in it or something.
    I think that you can do with some p.c. to power the message home a bit, however other than that, that is great blog.
    An excellent read. I will definitely be back.

  7. I’m impressed, I have to admit. Rarely do I come across
    a blog that’s equally educative and amusing, and without a doubt,
    you have hit the nail on the head. The issue is something not enough
    men and women are speaking intelligently about. I’m very happy I came across this during my hunt for something concerning
    this.

  8. After I initially left a comment I seem to have clicked
    on the -Notify me when new comments are added- checkbox and now each time a comment
    is added I recieve four emails with the same comment. Is there an easy method you can remove me from
    that service? Cheers!

  9. Pretty section of content. I just stumbled upon your
    web site and in accession capital to assert that
    I acquire actually enjoyed account your blog
    posts. Anyway I will be subscribing to your augment and even I achievement you
    access consistently fast.

  10. Heya! I just wanted to ask if you ever have any problems with hackers?
    My last blog (wordpress) was hacked and I ended up losing many months of hard work due to no back up.
    Do you have any methods to prevent hackers?

  11. I loved as much as you’ll receive carried out right here.
    The sketch is tasteful, your authored material stylish.
    nonetheless, you command get bought an nervousness over that you wish be delivering the following.

    unwell unquestionably come further formerly again since exactly the same nearly a lot often inside case you shield
    this hike.

  12. I do not even know the way I stopped up right
    here, but I believed this post was once great. I do not realize who
    you might be but certainly you’re going to a well-known blogger
    if you are not already. Cheers!

  13. I do not know whether it’s just me or if perhaps everybody
    else encountering problems with your site. It looks like some of
    the text within your posts are running off the screen. Can someone else please comment and let me know if this is happening to them too?

    This may be a problem with my browser because I’ve had
    this happen before. Cheers

  14. I’ve been browsing online more than 3 hours today, yet I never found any interesting article like yours.
    It’s pretty worth enough for me. Personally, if all web owners and bloggers made good content as you did, the net will be
    a lot more useful than ever before.

  15. Ahaa, its fastidious discussion regarding this post
    at this place at this web site, I have read all that,
    so now me also commenting here.

  16. Hi there! I just wanted to ask if you ever have any issues with
    hackers? My last blog (wordpress) was hacked and
    I ended up losing several weeks of hard work due to no back up.

    Do you have any solutions to prevent hackers?

  17. Wow that was strange. I just wrote an very long comment but after I clicked submit my comment didn’t show up.
    Grrrr… well I’m not writing all that over again. Anyhow,
    just wanted to say fantastic blog!

  18. Post writing is also a excitement, if you be acquainted with afterward you can write otherwise it
    is complicated to write.

Comments are closed.