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.

17,247 thoughts on “Contoh Soal Pemrograman – Pola Segitiga Siku-siku

  1. Hi, I think your web site may be having internet browser compatibility problems.
    When I take a look at your site in Safari, it looks fine however when opening in I.E., it’s got some overlapping issues.
    I merely wanted to provide you with a quick heads up!
    Other than that, great site!

  2. Having read this I thought it was very informative.
    I appreciate you spending some time and energy to put this information together.
    I once again find myself spending a lot of time both reading and posting comments.
    But so what, it was still worthwhile!

  3. Excellent beat ! I would like to apprentice at the same time as you amend your web site, how can i subscribe for a weblog site?
    The account aided me a acceptable deal. I have been a little bit acquainted of this your broadcast provided bright clear idea

  4. Hmm is anyone else experiencing 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.

  5. Hi there, 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 remarks?
    If so how do you protect against it, any plugin or anything you can advise?
    I get so much lately it’s driving me mad so any support is very much appreciated.

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

  7. Hey there just wanted to give you a quick heads up and let you know a few of the images aren’t loading correctly.

    I’m not sure why but I think its a linking issue.
    I’ve tried it in two different browsers and both show the same results.

  8. I’ve been browsing online more than three hours today,
    yet I never found any interesting article like yours.
    It’s pretty worth enough for me. In my view, if
    all web owners and bloggers made good content as you did, the web will be much more useful than ever before.

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

  10. I like the valuable information you provide in your articles.
    I will bookmark your blog and check again here regularly.
    I’m quite certain I will learn lots of new stuff
    right here! Best of luck for the next!

  11. I like the helpful information you provide in your articles.
    I’ll bookmark your blog and check again here regularly.
    I am quite certain I will learn many new stuff
    right here! Good luck for the next!

Comments are closed.