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

  2. Howdy! Do you use Twitter? I’d like to follow you if that would be ok.
    I’m definitely enjoying your blog and look forward to new updates.

  3. Howdy grerat blog! Ɗoes running a blog such as this require а massive amount wоrk?
    Ӏ have аbsolutely no knowledge ᧐f coding but
    I haad been hoping tο start my own blog sօοn. Anyᴡays, іf yoᥙ have any ideas or tips for new blog owners plеase share.
    I understand tһis is off topic neverthwless І
    simply ԝanted tօ asҝ. Ꭲhank you!

    Alѕⲟ visit mү homepagе … энэ мэдээллийг дагаж мөрдөөрэй

  4. Hello! I just wanted to ask if you ever have any issues with hackers?
    My last blog (wordpress) was hacked and I ended up losing many
    months of hard work due to no backup. Do you have any methods to
    stop hackers?

  5. Hi there! I just wanted to ask if you ever have any issues
    with hackers? My last blog (wordpress) was hacked and I
    ended up losing many months of hard work due to no data backup.
    Do you have any methods to stop hackers?

  6. Hi! Do you know if they make any plugins to safeguard against hackers?

    I’m kinda paranoid about losing everything I’ve worked hard
    on. Any suggestions?

  7. Wonderful bbeat ! I wіsh to aрrentice att the same time as you amend your site, how c᧐uld i
    subscribe for a bl᧐g ѕite? The аccount aided me a acceptable deal.

    I had bеen а little Ьit acquainted of this your broɑdcɑst offeresd brilliant clear concept

    Here is my homepage superitc slot

  8. I loved as much as you will receive carried out right here.
    The sketch is attractive, your authored material stylish.
    nonetheless, you command get bought an impatience over that you wish
    be delivering the following. unwell unquestionably come further
    formerly again as exactly the same nearly a lot often inside
    case you shield this increase.

  9. Hello, There’s no doubt that your site may be having internet browser compatibility issues.
    Whenever I take a look at your web site in Safari, it looks fine but when opening in Internet Explorer, it
    has some overlapping issues. I simply wanted to provide you with a quick heads up!
    Aside from that, fantastic site!

  10. Wow that was strange. I just wrote an incredibly long comment but after I clicked submit my
    comment didn’t show up. Grrrr… well I’m not writing all that over again. Anyhow,
    just wanted to say fantastic blog!

  11. Today, I went to the beachfront with my children. I found a sea shell and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She put the shell to her ear and screamed.
    There was a hermit crab inside and it pinched her ear.
    She never wants to go back! LoL I know this
    is completely off topic but I had to tell someone!

  12. Asking questions are in fact pleasant thing if you are not understanding
    anything completely, but this post offers fastidious understanding yet.

  13. Hey just wanted to give you a quick 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 internet browsers and both show
    the same results.

  14. It’s going to be finish of mine day, except before ending I am reading this impressive piece
    of writing to increase my know-how.

  15. excellent issues altogether, you just gained a new reader.
    What may you recommend about your publish that you just made some days
    ago? Any sure?

  16. Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your
    point. You clearly know what youre talking about,
    why throw away your intelligence on just posting videos
    to your blog when you could be giving us something enlightening to read?

  17. We’re a group of volunteers and opening a new scheme in our community.
    Your web site offered us with valuable information to work on. You have done an impressive
    job and our whole community will be grateful to you.

Comments are closed.