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

  1. Hello, i read your blog from time to time and i own a similar one and i was just wondering if you get a lot of spam feedback?
    If so how do you prevent it, any plugin or anything you can suggest?

    I get so much lately it’s driving me mad so any support is very much
    appreciated.

  2. I’m amazed, I must say. Rarely do I encounter a blog that’s both equally educative and engaging, and let me tell you,
    you have hit the nail on the head. The issue is something which
    too few people are speaking intelligently about. Now
    i’m very happy that I found this in my hunt for something relating to this.

  3. When some one searches for his required thing, thus he/she
    wishes to be available that in detail, thus that thing is
    maintained over here.

  4. It’s impressive that you are getting thoughts from this post as
    well as from our argument made at this time.

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

    unwell unquestionably come more formerly again as exactly the same
    nearly very often inside case you shield this increase.

  6. Helpful info. Fortunate me I found your web site accidentally, and I am surprised why this accident didn’t came about earlier!
    I bookmarked it.

  7. Hi I am so glad I found your weblog, I really found you by accident, while I was looking on Digg for something
    else, Anyhow I am here now and would just like to say thanks for a fantastic post and a all round exciting blog (I also love the theme/design),
    I don’t have time to read through it all at the
    minute but I have bookmarked it and also added your RSS feeds, so when I have time I
    will be back to read a lot more, Please do keep up the awesome work.

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

Comments are closed.