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! I just wanted to ask if you ever have any trouble with hackers?
    My last blog (wordpress) was hacked and I ended up losing a few months of hard work due to no
    data backup. Do you have any methods to protect against hackers?

  2. I am extremely impressed with your writing skills and also with the layout on your blog.
    Is this a paid theme or did you customize it yourself?
    Either way keep up the nice quality writing, it is rare to see a great
    blog like this one today.

  3. Its like you read my thoughts! You appear to know a lot approximately this, such as you
    wrote the guide in it or something. I think that you can do with
    some % to drive the message house a bit, however instead of that, that is great blog.

    A fantastic read. I will certainly be back.

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

  5. Hi, I do think this is a great web site. I stumbledupon it 😉 I will revisit yet again since I book marked it.
    Money and freedom is the greatest way to change, may you be rich and continue to guide others.

  6. I don’t even understand how I ended up here, but I thought this publish used to be great.
    I don’t recognize who you’re however certainly you are going to
    a famous blogger for those who aren’t already. Cheers!

  7. Howdy! Someone in my Facebook group shared this site with
    us so I came to look it over. I’m definitely enjoying the information. I’m book-marking
    and will be tweeting this to my followers! Fantastic blog and fantastic design.

  8. I like the helpful information you supply on your articles.
    I’ll bookmark your weblog and check again right here
    regularly. I am moderately certain I will learn plenty of new stuff proper here!
    Good luck for the following!

  9. I think the admin of this site is actually working hard in favor
    of his site, for the reason that here every information is quality based stuff.

  10. I do not even know how I ended up here, but I thought this post was
    good. I do not know who you are but definitely you are going to a famous blogger if you aren’t already ;
    ) Cheers!

  11. you’re actually a just right webmaster. The web site loading
    speed is incredible. It seems that you are doing any unique trick.

    In addition, The contents are masterpiece. you’ve performed a
    magnificent job in this subject!

  12. When I initially commented I clicked the “Notify me when new comments are added” checkbox and now each
    time a comment is added I get three emails with the same comment.
    Is there any way you can remove me from that service?
    Cheers!

  13. Howdy this is kind of of off topic but I was wondering if blogs use WYSIWYG editors or if you have to manually code with HTML.

    I’m starting a blog soon but have no coding expertise so I wanted to get guidance from someone with experience.

    Any help would be enormously appreciated!

  14. Its like you read my mind! You appear to know a lot about this, like you
    wrote the book in it or something. I think that you could do with a few pics
    to drive the message home a little bit, but instead
    of that, this is magnificent blog. A fantastic
    read. I will definitely be back.

Comments are closed.