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,210 thoughts on “Contoh Soal Pemrograman – Pola Segitiga Siku-siku

  1. Can I simply just say what a relief to uncover someone that really understands
    what they’re discussing over the internet.
    You actually understand how to bring a problem to
    light and make it important. More and more people should look at this and understand this side of your story.
    I was surprised that you are not more popular because you definitely have the gift.

  2. Attractive section of content. I just stumbled upon your site and in accession capital
    to assert that I get in fact enjoyed account your
    blog posts. Any way I’ll be subscribing to your augment and even I achievement you access consistently quickly.

  3. You actually make it appear really easy along with your presentation however I to find this
    topic to be really something that I feel I might by no means understand.
    It sort of feels too complex and extremely extensive for me.
    I am taking a look forward in your subsequent put up,
    I will attempt to get the dangle of it!

  4. The other day, while I was at work, my sister stole my apple ipad and
    tested to see if it can survive a 25 foot drop,
    just so she can be a youtube sensation. My iPad is now destroyed
    and she has 83 views. I know this is completely off
    topic but I had to share it with someone!

  5. you’re in reality a good webmaster. The site
    loading pace is incredible. It kind of feels that you’re doing
    any distinctive trick. In addition, The contents are
    masterwork. you have performed a great job on this topic!

  6. I was curious if you ever thought of changing the structure of your blog?
    Its very well written; I love what youve got to say.
    But maybe you could a little more in the way of content so people could connect with it better.
    Youve got an awful lot of text for only having one or two pictures.
    Maybe you could space it out better?

  7. Hello, i think that i noticed you visited my web site thus
    i came to return the favor?.I’m attempting to in finding issues to improve my site!I suppose its
    adequate to use some of your ideas!!

  8. Its such as you learn my thoughts! You seem to know so much approximately this, such as you wrote the e-book
    in it or something. I feel that you simply could do with a few percent to power the message home a little bit, however instead of
    that, this is great blog. A great read. I
    will certainly be back.

  9. I don’t know if it’s just me or if everyone else encountering problems with your blog.
    It appears like some of the written text on your content are running off the screen.
    Can somebody else please comment and let me know
    if this is happening to them as well? This may be a issue with
    my internet browser because I’ve had this happen before.

    Thanks

  10. Heya i am for the primary time here. I came across this board and I to find It truly helpful & it helped me out a lot.
    I’m hoping to present one thing back and help others like you helped
    me.

  11. Good day! This is my first visit to your blog!
    We are a collection of volunteers and starting a new initiative in a
    community in the same niche. Your blog provided us useful information to work on. You
    have done a extraordinary job!

  12. I’ve been exploring for a bit for any high-quality articles or blog posts on this sort of space .
    Exploring in Yahoo I at last stumbled upon this website.
    Reading this info So i am satisfied to express that I have a very good uncanny feeling I found out exactly what I
    needed. I such a lot surely will make sure to don?t overlook this site and provides it a
    glance on a continuing basis.

  13. I don’t even know how I ended up here, but I thought this post was great.

    I do not know who you are but definitely you are going to a famous blogger
    if you aren’t already 😉 Cheers!

  14. Heya fantastic blog! Does running a blog like
    this take a large amount of work? I have absolutely no knowledge
    of coding but I was hoping to start my own blog soon. Anyway,
    if you have any ideas or tips for new blog owners please
    share. I know this is off topic nevertheless I simply had to ask.
    Cheers!

  15. My developer is trying to persuade 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 a number of websites for about a year and am nervous about switching to another platform.
    I have heard good things about blogengine.net. Is there
    a way I can import all my wordpress posts into it? Any
    help would be really appreciated!

Comments are closed.