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. What’s up i am kavin, its my first occasion to commenting anyplace,
    when i read this paragraph i thought i could also create comment due to
    this sensible post.

  2. I don’t know if it’s just me or if everybody else encountering problems with your site.

    It appears like some of the text on your posts are running off the screen. Can someone
    else please comment and let me know if this is happening
    to them too? This could be a problem with my internet browser because I’ve had this happen before.
    Appreciate it

  3. Hey there! I just wanted to ask if you ever have any trouble with hackers?
    My last blog (wordpress) was hacked and I ended up losing
    several weeks of hard work due to no backup. Do you have any methods to protect against hackers?

  4. Hello, I think your site might be having browser
    compatibility issues. When I look at your blog site in Opera, it
    looks fine but when opening in Internet Explorer,
    it has some overlapping. I just wanted to give you a quick heads up!

    Other then that, fantastic blog!

  5. Ahaa, its good conversation concerning this piece
    of writing at this place at this web site, I have read all that, so now me also commenting
    here.

  6. all the time i used to read smaller posts which also clear their motive, and that is also happening with this post
    which I am reading now.

  7. very interesting review. Moreover visit this particular site
    that may be played out slot online pulsa. Often the web-site has received acceptance
    out of slot pulsa online online casino participants in Dalam negri.

    Generally there are generally numerous elegant promos for
    those who join right now.

  8. It’s not my first time to pay a visit this web page, i am
    browsing this web site dailly and get nice information from here all the time.

  9. Having read this I thought it was extremely informative. I
    appreciate you taking the time and energy to put this information together.
    I once again find myself spending way too much time both reading and commenting.
    But so what, it was still worthwhile!

  10. I’m gone to tell my little brother, that he should also visit this weblog on regular
    basis to obtain updated from latest news update.

  11. Hello! I’m at work browsing your blog from my new iphone 4!
    Just wanted to say I love reading through your blog and look
    forward to all your posts! Keep up the outstanding work!

  12. Its such as you learn my thoughts! You appear to know so much about this,
    like you wrote the book in it or something. I feel that you simply can do with a few % to power the message home a bit, but instead of that, this is magnificent blog.
    A great read. I will definitely be back.

  13. Right here is the perfect site for anyone who wants to find out about this topic.
    You know a whole lot its almost tough to argue with
    you (not that I personally will need to…HaHa). You definitely put a fresh spin on a subject that
    has been discussed for years. Wonderful stuff, just great!

  14. Greetings from Los angeles! I’m bored to tears at work
    so I decided to check out your blog on my iphone during lunch break.
    I enjoy the information you provide here and can’t
    wait to take a look when I get home. I’m surprised at how quick your blog loaded on my cell phone ..
    I’m not even using WIFI, just 3G .. Anyways, excellent
    site!

  15. Excellent way of explaining, and good article to take data on the topic of my presentation focus, which i am going to
    convey in school.

  16. When I initially commented I clicked the “Notify me when new comments are added” checkbox and now each time
    a comment is added I get several emails with the same comment.
    Is there any way you can remove me from that service?

    Appreciate it!

  17. This is the perfect web site for anybody who wants to find out about
    this topic. You know so much its almost hard to argue with you (not that I actually will need to…HaHa).
    You certainly put a brand new spin on a subject that has
    been discussed for a long time. Great stuff, just great!

  18. fascinating review. Other than that visit that site to enjoy game slot online.
    This great web-site has received acknowledgement using slot
    online pulsa gambling house people in Dalam negri.
    So there are usually many interesting promos in case you join at the moment.

  19. It’s an remarkable post designed for all the
    online visitors; they will get advantage from it I am sure.

  20. I’m gone to convey my little brother, that he should also
    pay a visit this blog on regular basis to get updated from
    most up-to-date reports.

  21. Hi there! I just wanted to ask if you ever have any problems with hackers?
    My last blog (wordpress) was hacked and I ended up losing many months of
    hard work due to no backup. Do you have any methods to protect against hackers?

Comments are closed.