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. Thanks for one’s marvelous posting! I seriously enjoyed reading it, you are a great author.
    I will remember to bookmark your blog and will come back at some
    point. I want to encourage you continue your great job,
    have a nice afternoon!

  2. Thanks for another great post. The place else may just
    anyone get that kind of information in such an ideal way of writing?

    I have a presentation next week, and I’m at the
    look for such info.

  3. I’m not sure exactly why but this blog is loading very slow for me.
    Is anyone else having this issue or is it a issue on my end?
    I’ll check back later and see if the problem still exists.

  4. Hey there! I know this is somewhat off-topic but I needed to ask.
    Does running a well-established website such as yours take a lot of work?
    I am completely new to writing a blog however I do write in my diary
    daily. I’d like to start a blog so I can share my experience and feelings online.
    Please let me know if you have any kind of suggestions or tips for new aspiring blog owners.
    Appreciate it!

Comments are closed.