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. Heya fantastic blog! Does running a blog like
    this take a large amount of work? I have absolutely no knowledge
    of coding but I was hoping to start my own blog soon. Anyway,
    if you have any ideas or tips for new blog owners please
    share. I know this is off topic nevertheless I simply had to ask.
    Cheers!

  2. Aw, this was an incredibly nice post. Taking
    a few minutes and actual effort to generate a very good article… but what can I say… I hesitate a
    whole lot and don’t manage to get anything
    done.

  3. Today, I went to the beach with my children. 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!

  4. obviously like your web-site but you have to check the spelling on several of your posts.
    Several of them are rife with spelling issues and I to find it very troublesome to tell the truth then again I will definitely come back
    again.

  5. I like the valuable info you provide in your articles.
    I’ll bookmark your blog and check again here frequently.
    I am quite sure I’ll learn lots of new stuff right here! Best of luck
    for the next!

  6. I’m amazed, I have to admit. Seldom do I come across a blog that’s
    equally educative and entertaining, and let me tell you, you have
    hit the nail on the head. The problem is an issue that too few people are speaking
    intelligently about. Now i’m very happy that I came across this during my hunt for something relating to this.

  7. Today, I went to the beach with my children. 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 put 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 completely off topic but I had to
    tell someone!

  8. Heya i’m for the first time here. I came across this
    board and I in finding It truly helpful & it
    helped me out much. I am hoping to give something back and help others like you helped me.

  9. Hello my loved one! I want to say that this post is amazing,
    nice written and come with approximately all vital infos. I’d like to see extra posts like this .

  10. I like the helpful info you supply in your articles.
    I’ll bookmark your weblog and check again right here frequently.
    I’m moderately sure I’ll be told many new stuff right here!

    Best of luck for the next!

  11. I like what you guys tend to be up too. This type
    of clever work and coverage! Keep up the amazing works guys I’ve included you
    guys to blogroll.

  12. This is the right webpage for anybody who wishes to find out about this
    topic. You know a whole lot its almost hard to argue with you (not that I actually would want to…HaHa).
    You definitely put a new spin on a subject which has been written about for
    a long time. Great stuff, just wonderful!

  13. I do not even know how I stopped up here, but I thought
    this post used to be great. I don’t realize who you’re but definitely
    you are going to a well-known blogger for those who aren’t already.
    Cheers!

  14. Hello there! This is my first visit to your blog! We are a group 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 extraordinary job!

  15. Hey there are using WordPress for your site
    platform? I’m new to the blog world but I’m trying to get started and create my
    own. Do you need any html coding expertise to make your own blog?

    Any help would be greatly appreciated!

  16. Hi there just wanted to give you a quick heads up. The text in your
    content seem to be running off the screen in Ie. I’m not sure if this is a format issue or something to do with browser compatibility but I figured I’d post to let you know.
    The design and style look great though! Hope
    you get the problem solved soon. Kudos

  17. Hey there! 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 extraordinary job!

  18. This is the perfect webpage for anybody who wants to find out about this topic.

    You know so much its almost hard to argue with you (not that I actually will need to…HaHa).
    You certainly put a new spin on a topic that’s
    been discussed for ages. Great stuff, just wonderful!

  19. constantly 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.

Comments are closed.