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. It’s really a nice and useful piece of info. I’m satisfied that you just shared this helpful info with us.
    Please keep us up to date like this. Thanks for sharing.

  2. Does your blog have a contact page? I’m having trouble 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 website and I look forward to seeing it expand over time.|

  3. Hi all, here every person is sharing these kinds of familiarity, therefore it’s fastidious to read this webpage,
    and I used to go to see this webpage all the time.

  4. I’m truly enjoying the design and layout of
    your website. It’s a very easy on the eyes which makes it
    much more enjoyable for me to come here and visit
    more often. Did you hire out a designer to create your theme?

    Exceptional work!

  5. Outstanding post however , I was wondering if you could write a litte more
    on this subject? I’d be very grateful if you could elaborate a little bit further.
    Cheers!

  6. I know this if off topic but I’m looking into starting
    my own weblog and was wondering what all is required to get setup?
    I’m assuming having a blog like yours would cost a pretty penny?
    I’m not very web smart so I’m not 100% certain. Any recommendations or advice would be greatly appreciated.
    Cheers

  7. Do you have a spam issue on this blog; I also
    am a blogger, and I was wanting to know your situation; we have developed some nice procedures
    and we are looking to trade methods with other folks, be sure to shoot me an e-mail
    if interested.

  8. I absolutely love your blog and find a lot of your post’s
    to be just what I’m looking for. Would you offer guest writers to write content available for you?
    I wouldn’t mind writing a post or elaborating on many of
    the subjects you write in relation to here. Again, awesome weblog!

  9. Its like you learn my thoughts! You seem to grasp a lot about this,
    such as you wrote the guide in it or something. I believe that you simply
    could do with a few p.c. to drive the message home a little bit, but
    other than that, this is excellent blog. A great read.

    I’ll certainly be back.

Comments are closed.