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, Neat post. There is an issue along with your website in internet explorer, may test this?
    IE still is the market chief and a large part of people will
    pass over your wonderful writing because of this problem.

  2. Hi! This is kind of off topic but I need some help from an established
    blog. Is it very difficult to set up your own blog?
    I’m not very techincal but I can figure things out pretty quick.
    I’m thinking about setting up my own but I’m not sure where to begin. Do you have
    any ideas or suggestions? Thank you

  3. This is really interesting, You’re a very skilled blogger.
    I’ve joined your feed and look forward to seeking more
    of your wonderful post. Also, I have shared your website
    in my social networks!

  4. Everyone loves what you guys are usually up too. This type
    of clever work and coverage! Keep up the amazing works
    guys I’ve added you guys to our blogroll.

  5. My partner and I stumbled over here coming
    from a different web address and thought I
    might as well check things out. I like what I see
    so i am just following you. Look forward to finding out about your web page for a second time.

  6. My programmer is trying to convince me to move to .net from PHP.
    I have always disliked the idea because of the
    expenses. But he’s tryiong none the less.
    I’ve been using Movable-type on several websites for about a year and am worried about switching to another platform.
    I have heard very good things about blogengine.net. Is there a
    way I can transfer all my wordpress content into it?

    Any help would be really appreciated!

  7. It’s perfect time to make some plans for the future and it’s time to be happy.
    I’ve read this post and if I could I desire to suggest you some
    interesting things or advice. Perhaps you could write next
    articles referring to this article. I wish to read more things about it!

  8. I really like your blog.. very nice colors & theme.
    Did you design this website yourself or did you
    hire someone to do it for you? Plz respond as I’m looking to create my own blog and would like to
    know where u got this from. thanks

  9. Hi, Neat post. There’s a problem together with your site in internet explorer,
    may test this? IE nonetheless is the marketplace chief and
    a good component to other folks will omit your magnificent writing due to this
    problem.

Comments are closed.