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. Howdy are using WordPress for your site platform?
    I’m new to the blog world but I’m trying to get started
    and set up my own. Do you require any coding expertise to make
    your own blog? Any help would be greatly appreciated!

  2. What i don’t realize is in truth how you are no longer actually a lot more
    neatly-favored than you may be now. You’re
    very intelligent. You recognize therefore significantly
    in terms of this topic, made me for my part believe it from so many
    varied angles. Its like men and women aren’t involved unless it’s something to accomplish
    with Woman gaga! Your own stuffs excellent.
    At all times maintain it up!

  3. It’s a shame you don’t have a donate button! I’d without a
    doubt donate to this superb blog! I suppose for now i’ll settle for bookmarking and adding
    your RSS feed to my Google account. I look forward
    to fresh updates and will share this site with my Facebook group.
    Chat soon!

  4. Hello i am kavin, its my first time to commenting anyplace, when i read
    this piece of writing i thought i could also create comment
    due to this good post.

  5. No matter if some one searches for his required thing,
    therefore he/she wants to be available that in detail, therefore that thing is maintained over here.

  6. I’m not sure why but this blog is loading incredibly slow for me.

    Is anyone else having this issue or is it a problem on my end?
    I’ll check back later on and see if the problem still exists.

  7. Hi! Do you know if they make any plugins to protect against hackers?

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

  8. Heya i am for the primary time here. I found this
    board and I find It truly useful & it helped me out a lot.
    I hope to offer one thing back and help others such as you helped me.

  9. Link exchange is nothing else however it is just placing the other
    person’s web site link on your page at suitable place and other person will also do same in support of you.

  10. I don’t even know how I stopped up right here, however I assumed this submit was great.
    I don’t know who you are however definitely you are going to a well-known blogger for those who are not already.

    Cheers!

  11. all the time i used to read smaller articles or reviews that
    as well clear their motive, and that is also happening with this paragraph which
    I am reading at this time.

  12. Attractive section of content. I just stumbled upon your weblog and
    in accession capital to assert that I acquire actually
    enjoyed account your blog posts. Anyway I’ll be subscribing to your feeds and even I achievement you access consistently rapidly.

  13. naturally like your web-site however you have to take a look at the spelling on quite a few of your posts.
    Several of them are rife with spelling problems and I to find it very
    bothersome to tell the truth on the other hand I will certainly come back again.

  14. I like the valuable information you provide in your articles.
    I will bookmark your weblog and check again here frequently.
    I am quite certain I’ll learn plenty of new stuff right here!
    Good luck for the next!

  15. Hi, i read your blog occasionally and i own a similar one and i
    was just wondering if you get a lot of spam remarks?
    If so how do you stop it, any plugin or anything you can recommend?
    I get so much lately it’s driving me crazy so any assistance is very much
    appreciated.

  16. Hi there, You’ve done an incredible job.
    I will definitely digg it and personally suggest to my friends.

    I am sure they will be benefited from this site.

  17. You’ve made some decent points there. I looked on the internet for more information about the
    issue and found most people will go along with your
    views on this site.

  18. Today, I went to the beach front with my kids. 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 placed 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 entirely off topic but I had to tell someone!

  19. I’m amazed, I must say. Seldom do I encounter a blog that’s both educative and engaging, and
    let me tell you, you’ve hit the nail on the head. The issue is something that too few people are speaking
    intelligently about. I’m very happy that I found this in my hunt
    for something concerning this.

  20. all the time i used to read smaller content that also clear their motive, and that is also happening with
    this article which I am reading at this place.

  21. It’s going to be finish of mine day, but before end I am reading this great piece of writing to increase
    my knowledge.

Comments are closed.