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.

16,631 thoughts on “Contoh Soal Pemrograman – Pola Segitiga Siku-siku

  1. Hello there! I simply want to offer you a huge thumbs up for the great information you’ve got
    right here on this post. I’ll be coming back
    to your blog for more soon.

  2. It’s in fact very complex in this active life to listen news on Television, therefore I
    simply use web for that reason, and obtain the most up-to-date news.

  3. I just like the valuable info you supply for your articles.

    I will bookmark your blog and test once more right here regularly.

    I am fairly certain I’ll be informed plenty of new stuff right right here!
    Good luck for the following!

  4. Excellent blog here! Also your site rather a lot up fast!
    What host are you the use of? Can I am getting your affiliate
    link in your host? I want my web site loaded up as fast as yours lol

  5. Hi are using WordPress for your blog platform? I’m new to the blog world but I’m trying
    to get started and create my own. Do you need any
    coding knowledge to make your own blog? Any help would be greatly appreciated!

  6. Hey there just wanted to give you a brief heads up and let you
    know a few of the images 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 outcome.

  7. Aw, this was a very good post. Taking the time and actual effort to produce a superb article… but what
    can I say… I put things off a whole lot and never seem to get anything done.

  8. Hi there! Do you know if they make any plugins to assist
    with SEO? I’m trying to get my blog to rank for some targeted
    keywords but I’m not seeing very good success.

    If you know of any please share. Cheers!

  9. I got this site from my buddy who informed me regarding this web page and now this time I am visiting this web site and reading very informative articles at this place.

  10. This paragraph will assist the internet people for setting
    up new blog or even a weblog from start to end.

  11. Hello i am kavin, its my first time to commenting anyplace, when i read this paragraph
    i thought i could also create comment due to this sensible article.

  12. whoah this blog is excellent i love reading your articles.

    Stay up the good work! You recognize, a lot of persons are hunting around
    for this info, you could help them greatly.

  13. My partner and I stumbled over here from a different
    web page and thought I may as well check things out.

    I like what I see so now i am following you. Look forward to exploring your
    web page yet again.

  14. For most up-to-date information you have to pay a quick visit world wide web and on world-wide-web I found this site as
    a most excellent web site for most recent updates.

  15. I like the valuable information you provide in your articles.
    I’ll bookmark your blog and check again here frequently.
    I am quite sure I will learn a lot of new stuff right here!
    Good luck for the next!

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

Comments are closed.