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 for … in.

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.

16,626 thoughts on “Contoh Soal Pemrograman – Pola Segitiga Siku-siku”

  1. Helpful information. Fortunate me I found your site accidentally, and I am surprised why this accident didn’t
    happened in advance! I bookmarked it.

  2. I do not even know how I ended up here, but I
    thought this post was great. I don’t know who you are but
    certainly you’re going to a famous blogger if you aren’t already
    😉 Cheers!

  3. Great beat ! I would like to apprentice even as you amend your site, how could i subscribe
    for a weblog web site? The account helped me a applicable deal.
    I had been tiny bit familiar of this your broadcast provided brilliant
    transparent idea

  4. Hi, I do believe this is an excellent blog. I stumbledupon it 😉 I’m going to return once again since I saved as a favorite it.

    Money and freedom is the best way to change, may you be rich and continue to guide
    others.

  5. Hi there! Do you know if they make any plugins to assist with Search Engine Optimization? I’m trying to
    get my blog to rank for some targeted keywords but I’m not seeing very good success.
    If you know of any please share. Appreciate it!

  6. I’m not sure exactly why but this blog is loading incredibly slow for me.
    Is anyone else having this problem or is it a problem on my end?
    I’ll check back later on and see if the problem still exists.

  7. Having read this I thought it was rather enlightening. I appreciate you taking the time and energy to put this information together.
    I once again find myself spending a lot of time both
    reading and leaving comments. But so what, it was still worth it!

  8. Hi every one, here every person is sharing these familiarity, so it’s fastidious to read this web site,
    and I used to pay a visit this weblog every
    day.

  9. Hmm is anyone else having problems with the images on this blog loading?
    I’m trying to determine if its a problem on my end or if it’s the blog.
    Any suggestions would be greatly appreciated.

  10. Admiring the hard work you put into your blog and detailed information you provide.
    It’s great to come across a blog every once in a while that isn’t the same out of date rehashed information. Fantastic read!
    I’ve saved your site and I’m adding your RSS
    feeds to my Google account.

  11. For latest news you have to visit internet and on internet I found this
    site as a finest web site for newest updates.

  12. When some one searches for his necessary thing, thus he/she wants to be available that in detail, therefore that thing is
    maintained over here.

  13. What’s up every one, here every one is sharing these kinds of knowledge,
    so it’s good to read this web site, and I used to visit this webpage every day.

  14. Hi there, I think your web site could possibly be having internet browser compatibility problems.
    When I look at your web site in Safari, it looks fine but when opening in IE, it’s got some overlapping issues.

    I merely wanted to give you a quick heads up! Apart from that, great site!

Comments are closed.