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

  1. Unquestionably believe that which you stated. Your favorite
    justification seemed to be on the internet the simplest thing to be aware of.
    I say to you, I definitely get annoyed while people consider worries that they plainly do not
    know about. You managed to hit the nail upon the top
    and defined out the whole thing without having side effect ,
    people could take a signal. Will likely be back to get more.
    Thanks

  2. Hi 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 web browsers and both show the same outcome.

  3. We absolutely love your blog and find the majority of your post’s to be precisely what I’m looking for. can you offer guest writers to write content for you personally? I wouldn’t mind publishing a post or elaborating on a lot of the subjects you write in relation to here. Again, awesome weblog!|

  4. 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 throw away
    your intelligence on just posting videos to your blog when you could
    be giving us something enlightening to read?

  5. First of all I would like to say terrific blog!
    I had a quick question that I’d like to ask if you don’t mind.

    I was curious to know how you center yourself and clear your thoughts before writing.
    I’ve had difficulty clearing my mind in getting my ideas out.
    I truly do enjoy writing but it just seems like
    the first 10 to 15 minutes are lost just trying to figure out how to begin. Any suggestions or tips?

    Thanks!

Comments are closed.