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

  1. Good day! I could have sworn I’ve visited your blog before but after browsing through some of the articles I realized it’s new
    to me. Nonetheless, I’m definitely pleased I found it and I’ll be book-marking it and
    checking back frequently!

  2. Excellent article. Keep writing such kind of
    information on your site. Im really impressed by it.
    Hey there, You’ve performed a great job. I’ll certainly digg it and for my part suggest to my friends.
    I’m sure they will be benefited from this site.

  3. Admiring the time and energy you put into your blog and detailed information you present.
    It’s good to come across a blog every once in a while that isn’t the same unwanted
    rehashed information. Excellent read! I’ve saved your site and I’m adding your RSS feeds to my
    Google account.

  4. Link exchange is nothing else but it is only placing the other person’s website link on your page at suitable place and other person will also do similar
    in favor of you.

  5. Your style is very unique in comparison to other people I have read stuff from.
    Thanks for posting when you’ve got the opportunity, Guess I will
    just bookmark this web site.

  6. Greetings from Idaho! I’m bored to death at work so I decided
    to check out your site on my iphone during lunch break.
    I love the information you present here and can’t wait
    to take a look when I get home. I’m surprised at how quick
    your blog loaded on my phone .. I’m not even using WIFI, just 3G ..

    Anyhow, amazing site!

Comments are closed.