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. Hey tһere! Tһis is кind of off topic ƅut I need sⲟmе help fr᧐m an established blog.
    Ιs iit difficult tо set up yօur own blog? I’m not
    vеry techincal but I can figure tһings out pretty quick.
    І’m thinking ɑbout creating my own ƅut I’m not sure
    ѡheгe to start. Do yоu have any points ᧐r suggestions?
    Ⅿany tһanks

    Mу web pаge … відкрий мене

  2. Do you have a spam issue on this website; I also am a blogger, and I was wanting to know your situation; we have developed some nice procedures and we are looking to trade solutions with other folks, be sure to shoot me an e-mail if interested.|

  3. I’m now not positive the place you’re getting your information, but good
    topic. I needs to spend a while studying more or figuring out more.
    Thanks for great information I was on the lookout
    for this info for my mission.

  4. Hi, i believe that i noticed you visited my website so i came to go
    back the prefer?.I’m attempting to in finding issues to improve my website!I suppose its ok to make
    use of some of your ideas!!

Comments are closed.