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,249 thoughts on “Contoh Soal Pemrograman – Pola Segitiga Siku-siku

  1. Attractive section of content. I simply stumbled upon your
    blog and in accession capital to say that I acquire
    actually enjoyed account your weblog posts. Anyway I’ll be subscribing in your feeds and even I achievement you access persistently quickly.

  2. Good post but I was wanting to know if you could write a litte more on this topic?
    I’d be very grateful if you could elaborate a little bit
    more. Cheers!

  3. It’s very trouble-free to find out any matter on net as compared
    to books, as I found this article at this web site.

  4. I just like the valuable info you provide in your articles.
    I’ll bookmark your weblog and test once more here regularly.
    I’m rather certain I will be told a lot of new stuff proper here!

    Best of luck for the following!

  5. Hi, i think that i saw you visited my weblog so
    i came to “return the favor”.I am trying to find things to improve my web site!I suppose its ok to use some of your
    ideas!!

  6. Wow, wonderful blog layout! How long have you been blogging for?
    you make blogging look easy. The overall look of your web site
    is great, as well as the content!

  7. Howdy! I know this is kinda off topic nevertheless I’d figured I’d ask.

    Would you be interested in exchanging links or maybe
    guest authoring a blog post or vice-versa? My site discusses a lot of the same subjects as yours
    and I believe we could greatly benefit from each other.

    If you might be interested feel free to shoot me an email.

    I look forward to hearing from you! Terrific blog
    by the way!

  8. Its such as you learn my thoughts! You appear to understand a lot about this, like you wrote the book in it
    or something. I feel that you could do with a few p.c.
    to force the message house a bit, but other than that,
    this is great blog. A fantastic read. I will certainly be back.

  9. Hi there it’s me, I am also visiting this web page on a regular
    basis, this web page is truly nice and the users are actually sharing nice thoughts.

  10. Hey just wanted to give you a quick heads up. The words in your article seem to
    be running off the screen in Internet explorer. I’m not sure if this is a format issue or something
    to do with internet browser compatibility but I thought I’d post to let you know.
    The design and style look great though! Hope you get the problem
    resolved soon. Kudos

  11. Hello i am kavin, its my first occasion to commenting anywhere, when i read this piece of writing i thought
    i could also create comment due to this good article.

  12. Having read this I believed it was rather informative.
    I appreciate you finding the time and energy to put this information together.
    I once again find myself spending way too much time both
    reading and leaving comments. But so what, it was still worth it!

  13. I have learn several just right stuff here. Certainly value
    bookmarking for revisiting. I wonder how much attempt you
    put to create one of these wonderful informative site.

  14. I’m truly enjoying the design and layout of your blog.
    It’s a very easy on the eyes which makes it much more enjoyable
    for me to come here and visit more often. Did you hire out a developer to create your theme?
    Superb work!

  15. Its like you learn my thoughts! You appear to know
    a lot approximately this, like you wrote the e book in it or something.
    I feel that you could do with some % to pressure the message house a little bit,
    however instead of that, that is great blog. A great read.
    I will definitely be back.

  16. Hey! This is my first visit to your blog! We are a team of volunteers and starting a new project in a community in the same niche.
    Your blog provided us beneficial information to work on. You have done a marvellous job!

  17. great put up, very informative. I wonder why the other experts of this sector do not notice this.
    You should continue your writing. I’m sure, you have a great
    readers’ base already!

  18. Hi this is somewhat of off topic but I was wanting to know if blogs use WYSIWYG
    editors or if you have to manually code with HTML. I’m starting a blog soon but have
    no coding experience so I wanted to get guidance from
    someone with experience. Any help would be greatly appreciated!

  19. Hi! This is my first visit to your blog! We are a team of volunteers and
    starting a new project in a community in the same niche. Your blog provided
    us useful information to work on. You have done a marvellous job!

  20. Incredible! This blog looks exactly like my old one!
    It’s on a entirely different subject but it has pretty much the same
    layout and design. Outstanding choice of colors!

  21. At this time it seems like Expression Engine is the preferred
    blogging platform out there right now. (from what I’ve read) Is that
    what you are using on your blog?

Comments are closed.