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 for … in.

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

  1. 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 waste your intelligence on just posting videos to your site when you could be giving us something
    informative to read?

  2. Hi! I know this is kinda off topic nevertheless I’d figured I’d ask.
    Would you be interested in exchanging links or maybe guest
    writing a blog article or vice-versa? My site discusses a
    lot of the same subjects as yours and I think we could greatly benefit from each
    other. If you happen to be interested feel free to shoot me an email.
    I look forward to hearing from you! Fantastic blog
    by the way!

  3. I’m impressed, I must say. Rarely do I come across a blog that’s both equally educative and interesting,
    and let me tell you, you have hit the nail on the head.
    The problem is something that too few people are speaking intelligently about.
    I’m very happy I found this during my search for something regarding this.

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

  5. A motivating discussion is definitely worth comment.

    I do think that you ought to publish more on this topic, it
    might not be a taboo subject but typically folks don’t discuss these subjects.
    To the next! Best wishes!!

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

  7. Hmm is anyone else experiencing problems with the pictures on this blog loading?
    I’m trying to determine if its a problem on my end or if it’s the blog.
    Any responses would be greatly appreciated.

  8. I know this web site gives quality depending posts and extra stuff, is there any other web page which provides these data in quality?

  9. Very nice post. I just stumbled upon your blog and wanted to say that
    I have truly enjoyed surfing around your blog posts.
    In any case I will be subscribing to your feed and I hope you
    write again soon!

  10. Hey would you mind letting me know which web host you’re using?
    I’ve loaded your blog in 3 completely different browsers and I must say this blog loads a lot quicker then most.
    Can you suggest a good hosting provider at a reasonable price?
    Cheers, I appreciate it!

  11. great issues altogether, you just received a logo new reader.
    What could you suggest in regards to your put up that you simply
    made a few days in the past? Any positive?

  12. I have learn some good stuff here. Definitely value
    bookmarking for revisiting. I wonder how much attempt you set to make such a wonderful informative web site.

  13. It’s the best time to make some plans for the long run and it’s time to be happy.
    I’ve read this post and if I could I want to counsel you some attention-grabbing issues or
    tips. Maybe you could write subsequent articles relating to
    this article. I wish to read even more things about it!

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

  15. Its like you read my mind! You seem to know a lot about this, like you wrote
    the book in it or something. I think that you can do with a few
    pics to drive the message home a little bit, but other than that, this is magnificent blog.
    A great read. I will definitely be back.

  16. Helpful info. Lucky me I discovered your web site by accident, and I’m
    shocked why this twist of fate didn’t came about in advance!
    I bookmarked it.

  17. These are truly impressive ideas in on the topic of blogging.
    You have touched some fastidious factors here.
    Any way keep up wrinting.

Comments are closed.