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.

17,247 thoughts on “Contoh Soal Pemrograman – Pola Segitiga Siku-siku

  1. I don’t even know how I ended up here, but I thought this post was good.
    I do not know who you are but definitely you’re going to a famous
    blogger if you are not already 😉 Cheers!

  2. СТАЦИОНАРНЫЕ (ПРОМЫШЛЕННЫЕ) АККУМУЛЯТОРЫ
    https://e-battery.ru/techtype/elektrotelezhki/
    О существовании т. н. тяговых аккумуляторов наверняка слышал каждый автомобилист. А вот для чего они придуманы, а также чем, собственно, отличаются от аккумуляторов обычных, знает, как ни странно, далеко не каждый водитель. Между тем, такие знания могли бы многим помочь на практике.

    ___________________________________________
    рекомотаранизм

  3. Does your blog have a contact page? I’m having a tough time locating it but, I’d like to shoot you an email.

    I’ve got some recommendations for your blog you might be interested in hearing.
    Either way, great blog and I look forward to seeing it expand over time.

  4. Admiring the commitment you put into your blog and detailed information you provide.
    It’s great to come across a blog every once in a while that isn’t the same out of
    date rehashed information. Wonderful read! I’ve
    saved your site and I’m adding your RSS feeds to
    my Google account.

  5. My family every time say that I am killing my time here at net, but I know I am getting know-how every day by
    reading thes fastidious posts.

Comments are closed.