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

  1. Right here is the right blog for everyone who really wants to find out about this topic. You know so much its almost hard to argue with you (not that I personally would want to…HaHa). You certainly put a fresh spin on a topic that’s been discussed for many years. Great stuff, just wonderful!|

  2. Hello there! This is kind of off topic but I need some advice
    from an established blog. Is it difficult to set up your own blog?

    I’m not very techincal but I can figure things out pretty quick.
    I’m thinking about making my own but I’m not sure where to start.

    Do you have any ideas or suggestions? Cheers

  3. Pretty nice post. I just stumbled upon your weblog and wanted to mention that I have really enjoyed surfing around
    your weblog posts. After all I’ll be subscribing in your rss feed and I am hoping you write
    again soon!

  4. How do you like this porn?
    https://noodlemagazine.com/watch/-167127135_456239953

    BDSM is bondage, discipline, domination, submission, sadism, and masochism – the favorite porn of those who read the book about “50 shades of gray”. However, in this porn, everything is an order of magnitude tougher. This is not vanilla movie shit for you, but a real genuine passion with tears, clips on nipples, a whipped red ass, chains and a pussy trembling from multiple orgasms.
    Outdoor – fucking in nature.
    BGG (Boy Girl Girl) – MZHM. Well, 2 women and one man. The dream of 95% of the male population of the planet has come true here.
    1200px-Kink_porn_shoot_09-1024×683
    Machines are usually fucking mechanical devices with rubber dicks on them.

Comments are closed.