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
Your detailed exposition certainly helped me a lot! Thank u
Respect from Algeria to you ..❤❤
Explaining all simple steps in each and every video....take a bow for your patience
Thank you :)
Wow mam!!! It's crystal clear mam !!!!great great very nicely explained 🙏Thank you so much ♥️
What a lucid explanation, thank you so much, madam. It was easily understood, especially for students from Non-IT branches like me.
It's my pleasure : )
thank you very much you made programming easy
thank you! your explanation was phenomenal
Glad it was helpful! :)
Thanks a lot! you are a saviour. God bless!
You're welcome! :)
Your explanations are very clear. Thanks
Thank you :)
Wow! explained things better than my CS teacher..
Thank you:)
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
@Morgan Matthias Definitely, been using instaflixxer for months myself :)
I love the way how u explain the detail. Love u
Thank you :)
Really love your videos about programming
Thank you :)
super explanation 👏👏👏totally understandable
Wow what a amazing explanation..
Very well explained..thanks
Wonderful explanation👏
Yes naming variables are good to see..they are very useful to understand easily..I preferred them mostly to students
Yes, true :)
mind blowing 👏👏
thank you so much
Thank you so much for your explanation! Your logic really helped with a javascript exercise.
Glad it helped! :)
Super explanation thank you 🙂
WOW!!! You deserve 10MILLION Subscribers!
❤️ Thank you 😊😊
It is so great ! Thanks.
excellent job! you explained very well.
Glad it was helpful! :)
awesome explanation. really liked your explanation... please keep up the good work
Thank you :)
awesome explained the logic,. really
loved this
Glad to hear that! :)
very good video, u explanation is very simply and logical
Glad it was helpful! :)
your explanation is great madam, thank you so much
You are most welcome :)
You Are Great
wow simply and really well explained
Thanks a lot 😊
thanks a lot man
SUPER NICE!!
Thank you :)
Thank u lot❤
very good job .. nice explanation
Thank you:)
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.
thanks alot god bless you
Thank you :)
THANKS A LOT!
Welcome :)
Very nice logic and very very nice explanation👌👌👌
Thank you so much 😀
@@AmulsAcademy I was thinking that while doing meditation instead of listening any another music i will listen you voice😄😄
thank you very very very mutch🌸🌸💜💜
Welcome:)
I am your fan
Thank you ❤️
Good explanation
Thank you :)
U r too good
انت مبدعه. ممتاز
you are legend i love you
Thank you :)
we are trying this pattern from last 6 days but nothing happens but you are love you
Thank you :)
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.
Thank you
You're welcome :)
wow what a logic
I want binomial coefficient in the form of equilateral triangle
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()
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?
Superb explanation can u help me in other code mam....
I will try :)
How to create this type thought in mind. Please tell mam.
I have only one doubt.... How do you number for column & rows as 0,1,2,... Or 1,2,3,...
How to print * replace with numbers
Please explained
why you started index value of row and coloumn as 1 instead of 0.
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
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.
:)
what to manipulate it for variable pattern range?
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()
:)
Mam, in second program even we can write as col%2!=0 instead of taking another variable.
You can try :)
I am getting error in elif row==n and column!=k
Can you please guide.
👍
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()
nter number of rows:5
* * * * * * * *********
there is no any mistake but the output is printing in horizontal way
In the Last line print() should be inside the first for loop.
Madam how to do print Hollow number traingle
Explanation
what if we want to give a constraint that n>2?
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()
hi! is it critical which "for" loop is to be the first one? a column loop or sting loop?
it is for row mate
@@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.
@@michaelshevelin2234 congrats 😎
*
* *
* *
* *
* *
* *
*
Ma'am i want to print this pattern plz help.
Same as the triangle you explained but inverted. Plz help
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.
how i print a string inside a triangle(The same as your triangle)
please help me
Give me the pattern please :)
i'm not able to get my desired output.can you please fix it out .
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=" ")
I love you madammm 😁
❣️❣️❣️
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()
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()
:)
Why my CS teacher doesn't explain Like This
how can we print inverted hollow pyramid with same logic? anyone?
Hello I want a code to print heart shape
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()
even after writing end i am not getting output in horizontal
Give me the program i will check :)
In row 4 two extra * us comming
give me the program please :)
*
* *
* *
*******
> This is th output I am getting with this code above
It's not working for left start triangle shape
In elif condition c%2!=0 if we write like dis we get output
We don't need to take k variable
Hello I have to clear 5 code test questions. .I need your help...will u help me out. As I have test tomorrow
All 5 questions are of python programming
Are u talking about whitehatjr??
mam this code does not work in python 3.7.4 what do i do
It should work in python 3.7.
getting any error?
it's working !!
i am getting syntax error at else:
Give me the program i will check :)
#how
Angel
You are soo cuute i love u ❤️❣️
Thank you :)
1,1,4,8,9,27,16,64 ye series list or for loop se kese solve hoge
Please solve this series
Ya fir is series se related series btao
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=" ")
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
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="")
:)
Mam Hindi me explain kijiye sabhi videos kko please
Not working for this
or miss
I m getting output wrong
Give me the program please :)
Ohh m sorry actually my mistake I give a space after end=" " that's why
Thankyou so much ma'am 😘😘
It's not working
Give me the program i will check :)
@@AmulsAcademy
No thanks madam I recognised the mistake I had done.once again tnx for responding mam