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. Asking questions are actually good thing if you are not understanding
    something entirely, however this paragraph offers pleasant understanding yet.

  2. I think that is one of the most important information for me.
    And i’m happy studying your article. But wanna statement on some basic issues, The site taste is perfect, the articles is actually nice : D.
    Good job, cheers

  3. I blog often and I truly appreciate your content.
    Your article has truly peaked my interest.
    I’m going to book mark your site and keep checking for new information about once a week.
    I subscribed to your Feed as well.

  4. My spouse and I stumbled over here different web page and thought I may as well check things out.

    I like what I see so now i’m following you. Look forward to exploring your web page for a second time.

  5. I pay a visit day-to-day a few web sites and sites to read posts, however this blog presents feature based posts.

  6. Admiring the hard work you put into your site and in depth
    information you present. It’s good to come across a blog every once
    in a while that isn’t the same outdated rehashed information. Excellent read!
    I’ve bookmarked your site and I’m including your RSS feeds to my Google account.

  7. Hi there! I just wanted to ask if you ever have any trouble with hackers?

    My last blog (wordpress) was hacked and I ended up losing many months of hard work due to no data backup.
    Do you have any methods to protect against hackers?

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

  9. I’m gone to say to my little brother, that he should also pay a quick visit this weblog on regular basis to get updated from latest gossip.

  10. Pretty part of content. I simply stumbled upon your weblog and in accession capital to claim that I get in fact loved account your blog posts.
    Anyway I will be subscribing to your augment and even I
    success you access persistently quickly.

  11. magnificent issues altogether, you simply received a emblem new reader.
    What might you recommend in regards to your submit that you simply made a few days in the past?
    Any positive?

  12. For most up-to-date news you have to pay a quick visit
    world-wide-web and on web I found this web
    page as a best web site for most up-to-date updates.

  13. Yesterday, while I was at work, my cousin stole my iphone and tested to see if it can survive a twenty five foot drop, just
    so she can be a youtube sensation. My iPad is now broken and she has 83 views.
    I know this is entirely off topic but I had to share it with someone!

  14. It’s not my first time to pay a quick visit this web site, i am browsing this site dailly and take good information from here everyday.

Comments are closed.