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.

17,247 thoughts on “Contoh Soal Pemrograman – Pola Segitiga Siku-siku

  1. Hey there would you mind letting me know which hosting company you’re using?
    I’ve loaded your blog in 3 different web browsers and I must say this blog loads a lot quicker then most.

    Can you recommend a good internet hosting provider at a fair price?
    Cheers, I appreciate it!

  2. Right here is the right site for anyone who wishes to understand this topic.
    You know a whole lot its almost hard to argue with you (not that I personally will need to…HaHa).
    You definitely put a new spin on a topic which has been discussed for many years.
    Excellent stuff, just excellent!

  3. เว็บตรง สล็อตฝากถอน ไม่มี ขั้นต่ำ
    1 บาทก็ ถอนได้ คืนยอดเสีย
    ยอมรับได้ในทันที เมื่อเข้าเล่นผ่านเว็บไซต์พวกเรา ที่ เว็บไซต์สล็อตแตกง่าย.NET ทำรายการฝากถอน ไม่มีขั้นต่ำ 1
    บาท ก็สามารถทำรายการได้ พร้อมรับโปรโมชั่นคืนยอดเสียสูงสุด ตามเงื่อนไขกำหนด 5% – 10% ซึ่งในส่วนของโปรโมชั่น เว็บตรงสล็อต ฝากถอนไม่มีขั้นต่ำ ทุกคนน่าจะติดต่อมาและสอบถามเนื้อหากับคณะทำงานผ่านทาง LINE
    ก่อนทุกครั้ง และนอกเหนือจากที่จะสามารถรับโปรโมชั่นจากเว็บไซต์เรา ในประเด็น เว็บตรง สล็อต ฝากถอนไม่มีอย่างต่ำ 1 บาท ก็ถอนได้
    ทางเรายังมีโปรโมชั่นสำหรับเกมได้รางวัล ฯลฯ ที่มอบให้กับสมาชิกเป็นของขวัญในปีใหม่ ปี 2022 เพียงแต่ ลงทะเบียนเป็นสมาชิก เล่นกับพวกเรา ลุ้นรับสิทธิพิเศษอีกเยอะมาก

  4. Hey! This is kind of off topic but I need some guidance from an established
    blog. Is it tough to set up your own blog? I’m not very techincal but I can figure things out pretty quick.
    I’m thinking about creating my own but I’m not sure where to start.
    Do you have any ideas or suggestions? Cheers

  5. This is very interesting, You’re a very skilled blogger.
    I’ve joined your rss feed and look forward to seeking more of your fantastic
    post. Also, I’ve shared your web site in my social networks!

  6. Hello just wanted to give you a brief heads up and let you know
    a few of the pictures aren’t loading correctly. I’m not sure why but I think its a linking issue.
    I’ve tried it in two different browsers and both show the same results.

Comments are closed.