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. We are a gaggle of volunteers and opening a new scheme in our community.
    Your web site provided us with useful info to work on. You
    have performed a formidable job and our entire group shall be
    grateful to you.

  2. Write more, thats all I have to say. Literally,
    it seems as though you relied on the video to make your point.
    You obviously know what youre talking about,
    why throw away your intelligence on just posting videos to your site when you could be giving us something informative to read?

  3. I’m wanting to download some videos from various different sites like youtube, Google videos, and a few other sites for my entertainment at home. I’ve downloaded an extension from Media Converter for Firefox, but I don’t see it anywhere. Can someone recommend an extension to allow me to download online videos?.

  4. Pretty nice post. I just stumbled upon your blog and wished to say that
    I’ve truly enjoyed surfing around your blog posts.
    After all I will be subscribing to your rss feed and I hope you write again soon!

  5. Right now it looks like BlogEngine is the best blogging platform out
    there right now. (from what I’ve read) Is that what you
    are using on your blog?

  6. Aw, this was an exceptionally good post. Taking the time
    and actual effort to generate a superb article… but what can I say… I put things off a whole lot and don’t manage to get anything done.

  7. Write more, thats all I have to say. Literally, it
    seems as though you relied on the video to make your point.

    You obviously know what youre talking about, why throw away your intelligence on just
    posting videos to your site when you could be giving us
    something informative to read?

  8. Hey! 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!

  9. Hey! This is my first visit to your blog! We are a team of volunteers and starting a
    new project in a community in the same niche. Your blog provided us valuable
    information to work on. You have done a outstanding job!

  10. I’ve been browsing online more than 3 hours today, yet I never found any interesting article like yours.

    It’s pretty worth enough for me. In my view,
    if all site owners and bloggers made good content as you did,
    the internet will be a lot more useful than ever before.

  11. Hello, i feel that i noticed you visited my site so i got here to return the desire?.I am trying to in finding issues to enhance my site!I guess its
    adequate to use a few of your ideas!!

  12. Hi my family member! I wish to say that this post is amazing,
    nice written and come with approximately all significant infos.
    I would like to see extra posts like this .

Comments are closed.