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

  1. I’m not sure where you are getting your information, but great topic.

    I needs to spend some time learning more or understanding more.
    Thanks for great info I was looking for this information for my mission.

  2. Новинки фільми, серіали, мультфільми 2021 року, які вже вийшли
    Ви можете дивитися українською на нашому сайті Ампир V

  3. Hey would you mind sharing which blog platform you’re using?
    I’m going to start my own blog in the near future but I’m having a tough time selecting between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your design seems different
    then most blogs and I’m looking for something unique.
    P.S Apologies for getting off-topic but I had to ask!

  4. I like the helpful information you provide in your articles.
    I will bookmark your weblog and test again here regularly.
    I am slightly certain I’ll be informed a lot of new stuff right right here!
    Best of luck for the following!

  5. Please let me know if you’re looking for a article writer for your blog.
    You have some really good posts and I think I would be a good asset.
    If you ever want to take some of the load off, I’d really like to write some material for your blog in exchange for a link back to mine.
    Please blast me an e-mail if interested. Thank you!

  6. At this moment I am going away to do my breakfast, after having my breakfast coming over again to
    read further news.

  7. An impressive share! I’ve just forwarded this onto a co-worker who has been doing a little homework on this.
    And he in fact bought me dinner due to the fact that I stumbled upon it for him…
    lol. So let me reword this…. Thanks for the meal!!
    But yeah, thanx for spending the time to talk about this matter here on your web site.

Comments are closed.