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 there just wanted to give you a quick heads up and let you know
    a few of the images aren’t loading correctly. I’m not sure why but I think
    its a linking issue. I’ve tried it in two different internet browsers and both show the same outcome.

  2. It’s in fact very complicated in this full of activity life to listen news on TV, so I only use world wide web for that reason, and obtain the most up-to-date
    news.

  3. I absolutely love your blog.. Great colors & theme.
    Did you develop this website yourself? Please reply back as I’m wanting to create my own site and
    want to find out where you got this from or what the theme is called.
    Appreciate it!

  4.  
    If you are likely to launch a web site in Nepal,
    there are many tips you must retain in mind. Among the most crucial
    tips to remember would be to keep track of your digital marketing metrics.
    This includes the total amount of traffic to your website, how many leads and sales, new versus repeat
    visitors, and the potency of your different channels.

    Tracking these metrics will allow you to to identify areas
    for improvement and adjust your strategy accordingly.

  5. Wow that was unusual. I just wrote an incredibly long comment but after I
    clicked submit my comment didn’t appear. Grrrr… well I’m not
    writing all that over again. Anyways, just wanted to say superb blog!

  6. Excellent post. I was checking constantly this blog and I am
    impressed! Extremely useful info particularly the last part :
    ) I care for such info a lot. I was looking for this certain information for a long time.

    Thank you and good luck.

Comments are closed.