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

  1. Oh my goodness! Incredible article dude! Many thanks, However I
    am encountering difficulties with your RSS. I don’t understand the reason why I
    can’t join it. Is there anyone else getting similar
    RSS problems? Anyone that knows the solution will you kindly respond?
    Thanks!!

  2. You are so awesome! I do not suppose I have read through anything like this before.
    So wonderful to find somebody with original thoughts on this topic.

    Seriously.. thank you for starting this up.
    This website is one thing that is needed on the web, someone with a little originality!

    Feel free to surf to my homepage boost testosterone levels

  3. We absolutely love your blog and find many of your post’s to be exactly I’m looking for. can you offer guest writers to write content to suit your needs? I wouldn’t mind producing a post or elaborating on most of the subjects you write concerning here. Again, awesome weblog!|

  4. What’s up to all, how is all, I think every one is getting more from this website,
    and your views are fastidious designed for new viewers.

  5. Hi there everyone, it’s my first pay a visit at this website, and
    piece of writing is genuinely fruitful in support of me, keep up posting these content.

  6. Superb blog! Do you have any recommendations for aspiring
    writers? I’m planning to start my own website soon but I’m a little
    lost on everything. Would you advise starting with a
    free platform like WordPress or go for a paid option? There
    are so many choices out there that I’m totally confused ..

    Any recommendations? Many thanks!

  7. I’m really loving the theme/design of your weblog. Do you ever run into any
    browser compatibility issues? A couple of my blog readers have complained about my blog not
    operating correctly in Explorer but looks
    great in Safari. Do you have any suggestions to help fix this
    issue?

    My web site: weed doctor websitehope

Comments are closed.