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

  1. You actually make it seem so easy with your presentation but
    I find this topic to be actually something that I think I would never understand.
    It seems too complex and very broad for me. I am looking forward for your next post,
    I’ll try to get the hang of it!

  2. Everything posted was actually very logical. However, think about this,
    suppose you were to write a killer headline? I ain’t suggesting your information isn’t
    solid, however what if you added a post title that grabbed people’s attention? I mean Contoh Soal
    Pemrograman – Pola Segitiga Siku-siku – Umar
    faisol is a little vanilla. You might glance at Yahoo’s home page and watch how they create article titles to get viewers
    to open the links. You might try adding a video or a related picture
    or two to grab people excited about what you’ve got to say.
    Just my opinion, it would make your website a
    little livelier.

Comments are closed.