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.

16,626 thoughts on “Contoh Soal Pemrograman – Pola Segitiga Siku-siku

  1. If some one wishes expert view about blogging and site-building after that
    i recommend him/her to pay a visit this webpage, Keep up the pleasant work.

  2. Hey there! I could have sworn I’ve been to this blog before
    but after browsing through some of the post I realized it’s new to me.
    Nonetheless, I’m definitely delighted I found it
    and I’ll be bookmarking and checking back frequently!

  3. I do not even know how I ended up here, but I thought this post was
    good. I don’t know who you are but definitely
    you’re going to a famous blogger if you aren’t already ;
    ) Cheers!

  4. Today, I went to the beachfront with my kids. I found a sea shell and gave it to my 4 year
    old daughter and said “You can hear the ocean if you put this to your ear.” She placed the
    shell to her ear and screamed. There was a hermit crab
    inside and it pinched her ear. She never wants to go back!
    LoL I know this is entirely off topic but I had to tell someone!

  5. Attractive element of content. I simply stumbled
    upon your web site and in accession capital to say that I get
    actually enjoyed account your weblog posts.
    Any way I’ll be subscribing on your feeds and even I success you
    access consistently rapidly.

  6. Ahaa, its fastidious conversation regarding this paragraph at this place at this
    weblog, I have read all that, so at this time me also commenting at this
    place.

  7. wonderful post, very informative. I’m wondering why the opposite experts
    of this sector don’t understand this. You must proceed your writing.

    I’m confident, you’ve a huge readers’ base already!

  8. I don’t know whether it’s just me or if everybody else encountering
    problems with your site. It appears as though some of the written text in your posts are running off the screen. Can somebody else please provide feedback and let
    me know if this is happening to them as well?
    This might be a problem with my web browser because I’ve had
    this happen previously. Appreciate it

  9. Its like you learn my thoughts! You seem to know a lot approximately this, like you wrote the
    guide in it or something. I think that you could do with a few p.c.
    to force the message home a little bit, however other than that,
    this is magnificent blog. An excellent read. I will definitely be
    back.

  10. Hi are using WordPress for your site platform? I’m new to the blog world but
    I’m trying to get started and set up my own. Do
    you need any html coding expertise to make your own blog?
    Any help would be greatly appreciated!

  11. Hi there! Someone in my Myspace group shared this site with us so I came to give it a look.
    I’m definitely loving the information. I’m bookmarking and will be tweeting this to my followers!
    Outstanding blog and fantastic style and design.

  12. I don’t even know the way I stopped up here, but I believed this publish
    was good. I do not know who you are however certainly you
    are going to a well-known blogger in the event you
    are not already. Cheers!

  13. Today, I went to the beach with my children. I found a sea shell
    and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.”
    She put the shell to her ear and screamed. There was a hermit crab inside and it
    pinched her ear. She never wants to go back!
    LoL I know this is totally off topic but I had to
    tell someone!

  14. Its such as you read my thoughts! You appear to know a lot
    about this, like you wrote the guide in it or something.
    I feel that you simply could do with a few percent to force the message
    house a bit, but instead of that, that is fantastic blog.
    A great read. I will definitely be back.

  15. 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!

  16. 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!

  17. 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

  18. 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.

Comments are closed.