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 for … in.

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. Hi there, I believe your web site could possibly be having internet browser compatibility problems.
    Whenever I look at your site in Safari, it looks fine but when opening
    in Internet Explorer, it’s got some overlapping issues. I simply wanted to give
    you a quick heads up! Aside from that, excellent site!

    Here is my site – slot online deposit lewat dana

  2. Hello i am kavin, its my first occasion to commenting anywhere, when i read this piece of writing i thought
    i could also make comment due to this good
    article.

  3. Wow, fantastic weblog structure! How lengthy have you ever been blogging for?
    you make running a blog glance easy. The entire glance of
    your web site is excellent, as neatly as the content material!

  4. I have been exploring for a little bit for any high quality
    articles or blog posts in this kind of area .
    Exploring in Yahoo I ultimately stumbled upon this web site.
    Studying this info So i am glad to exhibit that I’ve a very
    just right uncanny feeling I found out just what I needed.
    I such a lot unquestionably will make sure to do not overlook
    this web site and provides it a look regularly.

  5. Heya i’m for the first time here. I found this board and I in finding It truly useful & it helped me out much.
    I am hoping to provide something back and help others like you helped me.

  6. Hello, i read your blog occasionally and i own a similar one
    and i was just wondering if you get a lot of spam responses?
    If so how do you stop it, any plugin or anything you can advise?
    I get so much lately it’s driving me mad so any help is
    very much appreciated.

  7. Someone necessarily help to make seriously posts I’d state.
    That is the first time I frequented your web page and thus far?
    I surprised with the analysis you made to make this particular submit amazing.
    Great activity!

  8. Link exchange is nothing else but it is only placing the other person’s webpage link on your page at appropriate
    place and other person will also do same in favor of you.

  9. You can certainly see your skills in the work you write. The world hopes for
    more passionate writers such as you who are not afraid to
    say how they believe. At all times follow your
    heart.

  10. Hi there! This is my first visit to your blog! We are a collection 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 extraordinary job!

  11. of course like your web site however you need to take a look at the spelling on several of your posts.
    A number of them are rife with spelling issues and I to find it very bothersome to inform the
    reality then again I’ll surely come back again.

  12. Today, I went to the beach 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!

  13. Hi there just wanted to give you a quick
    heads up. The text in your article seem to be running off
    the screen in Internet explorer. I’m not sure if this is a formatting issue or something to
    do with browser compatibility but I figured I’d post
    to let you know. The layout look great though! Hope you get the issue fixed soon. Cheers

  14. I have been browsing online more than three hours today, yet I never
    found any interesting article like yours. It’s pretty worth enough for me.

    In my opinion, if all webmasters and bloggers made good
    content as you did, the net will be much more useful than ever before.

Comments are closed.