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

  1. اگر قصد خرید کاخن دارید و می خواهید بدانید بهترین برند کاخن کدام است این مقاله به بررسی ۷ برند برتر کاخن در جهان می پردازد.

  2. Hey I know this is off topic but I was wondering if you knew of any widgets
    I could add to my blog that automatically tweet my newest twitter
    updates. I’ve been looking for a plug-in like this for quite some time and was hoping maybe
    you would have some experience with something like this. Please let me know if you run into anything.
    I truly enjoy reading your blog and I look forward to your new updates.

  3. I truly love your blog.. Very nice colors & theme.
    Did you make this site yourself? Please reply back as I’m
    looking to create my very own site and would love to know where you got this from or
    just what the theme is called. Many thanks!

  4. Admiring the persistence you put into your website and in depth information you provide.
    It’s great to come across a blog every once in a while that isn’t the same
    unwanted rehashed information. Excellent read! I’ve bookmarked your site and I’m
    adding your RSS feeds to my Google account.

  5. Attractive portion of content. I simply stumbled upon your site and in accession capital to assert that I get actually
    loved account your blog posts. Anyway I will be subscribing
    for your feeds or even I fulfillment you get
    admission to persistently quickly.

Comments are closed.