Python Pattern Programs - Printing Stars in Hollow Equilateral Triangle Shape | Pyramid Pattern

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ธ.ค. 2017
  • In this Python Pattern Printing programs video tutorial you will learn to print stars in hollow right angle triangle shape in detail.
    To print stars in hollow equilateral triangle shape in python you have to use two for loops. the first loop is responsible for rows and the second for loop is responsible for column.next we need to use if else conditional statements. To write the conditions we used logical or operator.
    If you are using python 2 then in the above program you have to use print as statement and you cant use end in python 2, so
    print("*",end="")
    instead of this you have to use
    print "*",
    Thanks to Winter Arctic who gave the idea of using sum of row and column value.
    For more free tutorials on computer programming
    / amulsacademy
    / amulsacademy

ความคิดเห็น • 158

  • @cq7499
    @cq7499 4 ปีที่แล้ว +2

    Your detailed exposition certainly helped me a lot! Thank u

  • @DarkLord-vk5bt
    @DarkLord-vk5bt 9 หลายเดือนก่อน +1

    Respect from Algeria to you ..❤❤

  • @fareedsk6955
    @fareedsk6955 3 ปีที่แล้ว +1

    Explaining all simple steps in each and every video....take a bow for your patience

  • @vaishnavideshmukh3133
    @vaishnavideshmukh3133 ปีที่แล้ว

    Wow mam!!! It's crystal clear mam !!!!great great very nicely explained 🙏Thank you so much ♥️

  • @samanthshivakalimath4970
    @samanthshivakalimath4970 3 ปีที่แล้ว +3

    What a lucid explanation, thank you so much, madam. It was easily understood, especially for students from Non-IT branches like me.

  • @gauravrajguru393
    @gauravrajguru393 2 ปีที่แล้ว

    thank you very much you made programming easy

  • @juanandresblancoantezana7726
    @juanandresblancoantezana7726 3 ปีที่แล้ว +1

    thank you! your explanation was phenomenal

  • @akshatasurana1439
    @akshatasurana1439 4 ปีที่แล้ว +1

    Thanks a lot! you are a saviour. God bless!

  • @SJ-ic4yr
    @SJ-ic4yr 4 ปีที่แล้ว +1

    Your explanations are very clear. Thanks

  • @AmanKumar-sm2gi
    @AmanKumar-sm2gi 5 ปีที่แล้ว +26

    Wow! explained things better than my CS teacher..

    • @AmulsAcademy
      @AmulsAcademy  5 ปีที่แล้ว +1

      Thank you:)

    • @morganmatthias5684
      @morganmatthias5684 3 ปีที่แล้ว

      Dunno if you guys gives a damn but if you are bored like me during the covid times you can stream all of the latest movies and series on InstaFlixxer. Have been watching with my gf for the last few weeks xD

    • @kodajairo8193
      @kodajairo8193 3 ปีที่แล้ว

      @Morgan Matthias Definitely, been using instaflixxer for months myself :)

  • @shubhamsinha373
    @shubhamsinha373 3 ปีที่แล้ว +1

    I love the way how u explain the detail. Love u

  • @splendhacker1098
    @splendhacker1098 3 ปีที่แล้ว +2

    Really love your videos about programming

  • @prasanthpaul1354
    @prasanthpaul1354 ปีที่แล้ว

    super explanation 👏👏👏totally understandable

  • @droopy2145
    @droopy2145 ปีที่แล้ว

    Wow what a amazing explanation..

  • @shalinirakesh3455
    @shalinirakesh3455 2 ปีที่แล้ว

    Very well explained..thanks

  • @varshuk1934
    @varshuk1934 2 ปีที่แล้ว

    Wonderful explanation👏

  • @techmediaintelugu
    @techmediaintelugu 3 ปีที่แล้ว +2

    Yes naming variables are good to see..they are very useful to understand easily..I preferred them mostly to students

  • @shalupatidar2639
    @shalupatidar2639 ปีที่แล้ว

    mind blowing 👏👏
    thank you so much

  • @alee_matos
    @alee_matos 3 ปีที่แล้ว +2

    Thank you so much for your explanation! Your logic really helped with a javascript exercise.

  • @Musicalfly-xl2to
    @Musicalfly-xl2to ปีที่แล้ว

    Super explanation thank you 🙂

  • @mahtvabhushan5793
    @mahtvabhushan5793 3 ปีที่แล้ว +1

    WOW!!! You deserve 10MILLION Subscribers!

    • @AmulsAcademy
      @AmulsAcademy  3 ปีที่แล้ว

      ❤️ Thank you 😊😊

  • @enchanting-moist-brownie
    @enchanting-moist-brownie 2 ปีที่แล้ว

    It is so great ! Thanks.

  • @savitapallad9170
    @savitapallad9170 3 ปีที่แล้ว +1

    excellent job! you explained very well.

  • @phanirebba7065
    @phanirebba7065 3 ปีที่แล้ว +2

    awesome explanation. really liked your explanation... please keep up the good work

  • @shashankshekhar1208
    @shashankshekhar1208 3 ปีที่แล้ว +2

    awesome explained the logic,. really
    loved this

  • @mampisarkar1
    @mampisarkar1 3 ปีที่แล้ว +1

    very good video, u explanation is very simply and logical

  • @Music.Air99
    @Music.Air99 3 ปีที่แล้ว +1

    your explanation is great madam, thank you so much

  • @kaustubhzade9429
    @kaustubhzade9429 4 ปีที่แล้ว +1

    You Are Great

  • @NikankshaJain
    @NikankshaJain 3 ปีที่แล้ว +1

    wow simply and really well explained

  • @tarekghosn3648
    @tarekghosn3648 2 ปีที่แล้ว

    thanks a lot man

  • @tecolote8566
    @tecolote8566 3 ปีที่แล้ว +2

    SUPER NICE!!

  • @syedibramsha4499
    @syedibramsha4499 3 หลายเดือนก่อน +1

    Thank u lot❤

  • @ranjith7775
    @ranjith7775 6 ปีที่แล้ว +1

    very good job .. nice explanation

  • @music_lover_infinity
    @music_lover_infinity 2 ปีที่แล้ว +2

    n=int(input("enter a no."))
    for i in range(1,n+1):
    for j in range(1,n*2):
    if i+j==n+1 or j-i==n-1 or (i==n and j%2!=0):
    print("*",end="")
    else:
    print(" ",end="")
    print()
    by adding one more or operator we can make it short.

  • @ManpreetKaur-dl4of
    @ManpreetKaur-dl4of 4 ปีที่แล้ว +1

    thanks alot god bless you

  • @deideimanza5454
    @deideimanza5454 4 ปีที่แล้ว +1

    THANKS A LOT!

  • @KK7155.
    @KK7155. 3 ปีที่แล้ว +1

    Very nice logic and very very nice explanation👌👌👌

    • @AmulsAcademy
      @AmulsAcademy  3 ปีที่แล้ว

      Thank you so much 😀

    • @KK7155.
      @KK7155. 3 ปีที่แล้ว

      @@AmulsAcademy I was thinking that while doing meditation instead of listening any another music i will listen you voice😄😄

  • @aliamere7511
    @aliamere7511 6 ปีที่แล้ว +2

    thank you very very very mutch🌸🌸💜💜

  • @venkatkrishnan876
    @venkatkrishnan876 3 ปีที่แล้ว +1

    I am your fan

  • @crackexameasily786
    @crackexameasily786 3 ปีที่แล้ว +1

    Good explanation

  • @NoobNexus_Gaming
    @NoobNexus_Gaming 4 ปีที่แล้ว

    U r too good

  • @a11k60
    @a11k60 3 ปีที่แล้ว

    انت مبدعه. ممتاز

  • @nikhilsharma7741
    @nikhilsharma7741 3 ปีที่แล้ว +1

    you are legend i love you

  • @nikhilsharma7741
    @nikhilsharma7741 3 ปีที่แล้ว +1

    we are trying this pattern from last 6 days but nothing happens but you are love you

  • @divyarvikranth6224
    @divyarvikranth6224 5 ปีที่แล้ว +3

    Can u give code for the pattern similar to above. But the figure should turn towards it's right. The tip of this triangle should come towards right.

  • @techmediaintelugu
    @techmediaintelugu 3 ปีที่แล้ว +1

    Thank you

  • @manikandand2541
    @manikandand2541 4 ปีที่แล้ว

    wow what a logic

  • @sagilijayasree7740
    @sagilijayasree7740 4 ปีที่แล้ว +1

    I want binomial coefficient in the form of equilateral triangle

  • @naveenhagaragi8460
    @naveenhagaragi8460 4 ปีที่แล้ว

    Why to write elif condition, we can simply replace 'row==n' in 1st pgm with '(row==n and col%2!=0)' for 2nd pgm
    n=int(input("Enter number of rows: "))
    for row in range(1,n+1):
    for col in range(1,2*n):
    if (row+col==n+1) or (col-row==n-1) or (row==n and col%2!=0):
    print("*",end="")
    else:
    print(" ",end="")
    print()

  • @abhishekanand6425
    @abhishekanand6425 5 ปีที่แล้ว

    mam ye jo aapne general program likha hai maan lijiye agar isme col ki range (1,8) na hokr (1,7) hoti aur n ki value 4 hoti to kaise general range likhte col ke liye?

  • @salujamurali3514
    @salujamurali3514 3 ปีที่แล้ว +1

    Superb explanation can u help me in other code mam....

  • @smarttechnology4060
    @smarttechnology4060 4 ปีที่แล้ว

    How to create this type thought in mind. Please tell mam.

  • @esakkisankar30
    @esakkisankar30 ปีที่แล้ว

    I have only one doubt.... How do you number for column & rows as 0,1,2,... Or 1,2,3,...

  • @allinvrk1273
    @allinvrk1273 ปีที่แล้ว +1

    How to print * replace with numbers
    Please explained

  • @sandeepkumartiwari8436
    @sandeepkumartiwari8436 ปีที่แล้ว

    why you started index value of row and coloumn as 1 instead of 0.

  • @abhishekanand6425
    @abhishekanand6425 5 ปีที่แล้ว +1

    mam in this program if i select range for rows=(5) and col=(8) soo it shows error but when i choose range row=(1,5) and col=(1,8) then pattern is correct why please explain

    • @AmulsAcademy
      @AmulsAcademy  5 ปีที่แล้ว +1

      That program is written for row 1 to 5 and col 1 to 8.
      we wrote if condition based on that .
      And range(5) is different from range(1,5).
      range(5) = 0, 1, 2, 3, 4
      range(1,5) = 1, 2, 3, 4
      To make it work for rows(5), you need to change the conditions also.
      :)

  • @trickstar5732
    @trickstar5732 6 ปีที่แล้ว +2

    what to manipulate it for variable pattern range?

    • @AmulsAcademy
      @AmulsAcademy  6 ปีที่แล้ว +1

      num = int(input("eneter the number of rows:"))
      for row in range(num):
      for col in range((2*num)-1):
      if row==(num-1) or (row+col==(num-1)) or (col-row==(num-1)) :
      print("*",end="")
      else:
      print(end=" ")
      print()
      :)

  • @sowmyapola1363
    @sowmyapola1363 3 ปีที่แล้ว +1

    Mam, in second program even we can write as col%2!=0 instead of taking another variable.

  • @meenuturan6185
    @meenuturan6185 ปีที่แล้ว

    I am getting error in elif row==n and column!=k
    Can you please guide.

  • @PS-fc3hr
    @PS-fc3hr 4 ปีที่แล้ว

    👍

  • @Ramakrishna-et6gt
    @Ramakrishna-et6gt 3 ปีที่แล้ว

    n=int(input("enter number of rows:"))
    for row in range(1,n+1):
    for col in range(1,2*n):
    if row==n or row+col==n+1 or col-row==n-1:
    print("*",end="")
    else:
    print(end=" ")
    print()

    • @Ramakrishna-et6gt
      @Ramakrishna-et6gt 3 ปีที่แล้ว

      nter number of rows:5
      * * * * * * * *********

    • @Ramakrishna-et6gt
      @Ramakrishna-et6gt 3 ปีที่แล้ว +1

      there is no any mistake but the output is printing in horizontal way

    • @AmulsAcademy
      @AmulsAcademy  3 ปีที่แล้ว

      In the Last line print() should be inside the first for loop.

  • @vrakesh5288
    @vrakesh5288 2 ปีที่แล้ว

    Madam how to do print Hollow number traingle

  • @NoobNexus_Gaming
    @NoobNexus_Gaming 4 ปีที่แล้ว

    Explanation

  • @fakehakhan1146
    @fakehakhan1146 3 ปีที่แล้ว +1

    what if we want to give a constraint that n>2?

    • @AmulsAcademy
      @AmulsAcademy  3 ปีที่แล้ว

      Try this:
      n = int(input("rows:"))
      col=2*n-1
      mid=col//2
      for i in range(n):
      for j in range(col):
      if i+j==mid or j-i==mid or i==n-1:
      print("*",end="")
      else:
      print(" ",end="")
      print()

  • @michaelshevelin2234
    @michaelshevelin2234 4 ปีที่แล้ว

    hi! is it critical which "for" loop is to be the first one? a column loop or sting loop?

    • @zainabbohra2915
      @zainabbohra2915 2 ปีที่แล้ว

      it is for row mate

    • @michaelshevelin2234
      @michaelshevelin2234 2 ปีที่แล้ว

      @@zainabbohra2915Yeah, cheers dude:) My question is old and dumb. Ironically, last week I got a job in signal processing & machine learning. This is a reminder(to me at least) to be patient and helpful to beginners.

    • @zainabbohra2915
      @zainabbohra2915 2 ปีที่แล้ว

      @@michaelshevelin2234 congrats 😎

  • @sagnik0397
    @sagnik0397 3 ปีที่แล้ว +2

    *
    * *
    * *
    * *
    * *
    * *
    *
    Ma'am i want to print this pattern plz help.
    Same as the triangle you explained but inverted. Plz help

  • @kanchidoshi6907
    @kanchidoshi6907 2 ปีที่แล้ว

    How do you come up with the logic of row+col and col-row? I was thinking to calculate mid = n/2 and then display the * but it got complicated.

  • @naseemhamze11
    @naseemhamze11 3 ปีที่แล้ว +2

    how i print a string inside a triangle(The same as your triangle)
    please help me

    • @AmulsAcademy
      @AmulsAcademy  3 ปีที่แล้ว

      Give me the pattern please :)

  • @Dawoodbashir78
    @Dawoodbashir78 5 ปีที่แล้ว

    i'm not able to get my desired output.can you please fix it out .

    • @Dawoodbashir78
      @Dawoodbashir78 5 ปีที่แล้ว

      code is here:
      for row in range (0,3):
      for col in range (0,6):
      if row == 4 or row+col ==5 or col-row==3:
      print("*",end="")
      else:
      print(end=" ")

  • @battulasatish2589
    @battulasatish2589 ปีที่แล้ว

    I love you madammm 😁

  • @awais_ansarii
    @awais_ansarii 2 ปีที่แล้ว

    ❣️❣️❣️

  • @deeptigupta8291
    @deeptigupta8291 4 ปีที่แล้ว +2

    I am not getting correct output dear, this is my code:
    n=int (input("enter the number of row :"))
    for row in range (1,n+1):
    for col in range (1,2*n):
    if (row==n or row+col==n+1 or col-row==n-1):
    print("*",end="")
    else:
    print(end="")
    print()

    • @AmulsAcademy
      @AmulsAcademy  4 ปีที่แล้ว

      In the else print you need to print space :)
      n=int(input("enter the number of row :"))
      for row in range (1,n+1):
      for col in range (1,2*n):
      if (row==n or row+col==n+1 or col-row==n-1):
      print("*",end="")
      else:
      print(end=" ")
      print()
      :)

  • @SAITAMA-sm2du
    @SAITAMA-sm2du 2 ปีที่แล้ว +1

    Why my CS teacher doesn't explain Like This

  • @mibrahim2001
    @mibrahim2001 3 ปีที่แล้ว

    how can we print inverted hollow pyramid with same logic? anyone?

  • @educationforall6290
    @educationforall6290 6 ปีที่แล้ว +1

    Hello I want a code to print heart shape

    • @AmulsAcademy
      @AmulsAcademy  6 ปีที่แล้ว +1

      for row in range(5):
      for col in range(7):
      if (row==0 and col%3!=0) or (row==1 and col%3==0) or row-col==1 or row+col==7:
      print("*",end="")
      else:
      print(end=" ")
      print()

  • @kashmirikitchenfood8218
    @kashmirikitchenfood8218 4 ปีที่แล้ว +1

    even after writing end i am not getting output in horizontal

    • @AmulsAcademy
      @AmulsAcademy  4 ปีที่แล้ว

      Give me the program i will check :)

  • @rajeshwariyadav24
    @rajeshwariyadav24 5 ปีที่แล้ว +1

    In row 4 two extra * us comming

    • @AmulsAcademy
      @AmulsAcademy  5 ปีที่แล้ว

      give me the program please :)

  • @yesdone4993
    @yesdone4993 ปีที่แล้ว

    *
    * *
    * *
    *******
    > This is th output I am getting with this code above

  • @aniruddhadeshmukh3571
    @aniruddhadeshmukh3571 ปีที่แล้ว

    It's not working for left start triangle shape

  • @surendraavvaru4041
    @surendraavvaru4041 4 ปีที่แล้ว

    In elif condition c%2!=0 if we write like dis we get output

  • @sushmapatelia5545
    @sushmapatelia5545 3 ปีที่แล้ว

    Hello I have to clear 5 code test questions. .I need your help...will u help me out. As I have test tomorrow

    • @sushmapatelia5545
      @sushmapatelia5545 3 ปีที่แล้ว

      All 5 questions are of python programming

    • @afreenasgar7012
      @afreenasgar7012 3 ปีที่แล้ว

      Are u talking about whitehatjr??

  • @rahulsharma-rg9fx
    @rahulsharma-rg9fx 4 ปีที่แล้ว +1

    mam this code does not work in python 3.7.4 what do i do

  • @samarthdwivedi3358
    @samarthdwivedi3358 3 ปีที่แล้ว +2

    i am getting syntax error at else:

    • @AmulsAcademy
      @AmulsAcademy  3 ปีที่แล้ว

      Give me the program i will check :)

  • @trickstar5732
    @trickstar5732 6 ปีที่แล้ว

    #how

  • @5g3yashwanth71
    @5g3yashwanth71 2 ปีที่แล้ว

    Angel

  • @offshoring8197
    @offshoring8197 3 ปีที่แล้ว +2

    You are soo cuute i love u ❤️❣️

  • @ropiljain3526
    @ropiljain3526 5 ปีที่แล้ว

    1,1,4,8,9,27,16,64 ye series list or for loop se kese solve hoge

    • @ropiljain3526
      @ropiljain3526 5 ปีที่แล้ว

      Please solve this series

    • @ropiljain3526
      @ropiljain3526 5 ปีที่แล้ว

      Ya fir is series se related series btao

    • @monicasaha2906
      @monicasaha2906 4 ปีที่แล้ว

      n=int(input("enter the term:"))
      a=1
      for i in range (1,n+1):
      if(i%2==0):
      b=a**3
      a=a+1
      else:
      b=a**2
      print(b,end=" ")

  • @narendarallu4489
    @narendarallu4489 6 ปีที่แล้ว +2

    for row in range(1,5):
    for col in range(1,8):
    if (row==3 or row+col==5 or col-row==3):
    print("*",end="")
    else:
    print(" ")
    print() but i m getting output wrong mam

    • @AmulsAcademy
      @AmulsAcademy  6 ปีที่แล้ว +2

      for row in range(1,5):
      for col in range(1,8):
      if (row==4 or row+col==5 or col-row==3):
      print("*",end="")
      else:
      print(" ",end="")
      print()
      1. in the if condition you wrote row==3 but you want stars at row 4
      2. in the else part you need to include end ="" to keep the control in the same line.
      print(" ',end="")
      :)

  • @Manishyadav-gt1ju
    @Manishyadav-gt1ju 3 ปีที่แล้ว

    Mam Hindi me explain kijiye sabhi videos kko please

  • @aniruddhadeshmukh3571
    @aniruddhadeshmukh3571 ปีที่แล้ว

    Not working for this

  • @tarekghosn3648
    @tarekghosn3648 2 ปีที่แล้ว

    or miss

  • @rajeshwariyadav24
    @rajeshwariyadav24 5 ปีที่แล้ว +1

    I m getting output wrong

    • @AmulsAcademy
      @AmulsAcademy  5 ปีที่แล้ว

      Give me the program please :)

    • @rajeshwariyadav24
      @rajeshwariyadav24 5 ปีที่แล้ว +1

      Ohh m sorry actually my mistake I give a space after end=" " that's why

    • @rajeshwariyadav24
      @rajeshwariyadav24 5 ปีที่แล้ว +1

      Thankyou so much ma'am 😘😘

  • @DheerajKumar-yk3yl
    @DheerajKumar-yk3yl 3 ปีที่แล้ว +1

    It's not working

    • @AmulsAcademy
      @AmulsAcademy  3 ปีที่แล้ว

      Give me the program i will check :)

    • @DheerajKumar-yk3yl
      @DheerajKumar-yk3yl 3 ปีที่แล้ว

      @@AmulsAcademy
      No thanks madam I recognised the mistake I had done.once again tnx for responding mam