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. I like the helpful information you provide in your articles.
    I’ll bookmark your weblog and check again here regularly.
    I am quite certain I’ll learn lots of new stuff
    right here! Best of luck for the next!

  2. Ik someone who has one for £10. the captain. Made me love the yanks.
    I’m looking for them to do that. Point me in the right direction. It’d
    have a lot more weight if you put the real ones out
    with the fakes to see if the real ones passed auth.

    my homepage – take different sport

  3. Thank you a lot for sharing this with all folks you really recognise what you are
    talking about! Bookmarked. Please also seek advice from my website =).
    We can have a hyperlink change contract between us

  4. Attractive component of content. I just
    stumbled upon your website and in accession capital to claim that I get in fact enjoyed account your
    blog posts. Anyway I will be subscribing on your augment and even I
    fulfillment you get right of entry to constantly quickly.

  5. Greetings! I know this is kinda off topic however , I’d figured
    I’d ask. Would you be interested in trading links or maybe
    guest authoring a blog article or vice-versa? My website discusses
    a lot of the same topics as yours and I feel we
    could greatly benefit from each other. If you are interested feel free to send me an e-mail.
    I look forward to hearing from you! Excellent blog by the way!

Comments are closed.