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. If some one desires expert view on the topic of running a blog then i advise him/her to visit this web site, Keep up
    the pleasant job.

  2. We’re a group of volunteers and opening a new scheme in our community.
    Your site provided us with valuable info to work on. You’ve done a formidable job and our whole community will be grateful to you.

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

  4. Everyone loves what you guys are usually up too. Such clever work
    and coverage! Keep up the great works guys I’ve incorporated you guys to blogroll.

  5. Incredible! This blog looks just like my old one!
    It’s on a completely different subject but it has pretty much the same layout and
    design. Superb choice of colors!

  6. Excellent beat ! I wish to apprentice while you
    amend your site, how can i subscribe for a weblog site? The account
    aided me a acceptable deal. I had been a little bit acquainted of this your broadcast provided vibrant clear concept

  7. whoah this blog is fantastic i love reading your posts.
    Keep up the great work! You already know, a lot of people
    are hunting round for this information, you can aid them greatly.

  8. Wow that was odd. I just wrote an very long comment but after I clicked submit my comment didn’t appear.
    Grrrr… well I’m not writing all that over again. Anyhow, just
    wanted to say wonderful blog!

  9. I think the admin of this web page is in fact working hard in support of his site, as here every stuff is quality based data.

  10. 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 completely off topic but I had to tell someone!

  11. Have you ever thought about adding a little bit more than just your articles?
    I mean, what you say is fundamental and everything.
    Nevertheless think of if you added some great visuals or video clips to give your
    posts more, “pop”! Your content is excellent but with images and video
    clips, this site could definitely be one of the best in its field.
    Wonderful blog!

  12. Hola! I’ve been reading your weblog for a long time now and finally got the bravery to go ahead and give you a shout out from Kingwood
    Texas! Just wanted to tell you keep up the good work!

  13. Aw, this was an exceptionally good post. Finding the time and actual effort to make a top notch article…
    but what can I say… I procrastinate a lot and don’t seem to get anything done.

  14. I like the valuable info you supply for your articles.
    I will bookmark your weblog and check again right here regularly.
    I’m rather certain I’ll learn lots of new stuff proper
    here! Good luck for the following!

  15. Hello! I just wanted to ask if you ever have any
    problems with hackers? My last blog (wordpress) was hacked and I ended up losing several weeks of hard work due
    to no data backup. Do you have any methods to stop hackers?

  16. For the reason that the admin of this web page is
    working, no doubt very shortly it will be renowned, due
    to its feature contents.

  17. Hello, this weekend is fastidious for me, as this moment i am reading this fantastic informative paragraph here at my house.

  18. I do not even know the way I finished up here, but I believed this post was once good.
    I do not recognize who you might be however definitely you are
    going to a famous blogger if you happen to are
    not already. Cheers!

Comments are closed.