Python Pattern Programs | Printing Stars '*' in A Shape
Вставка
- Опубліковано 13 жов 2024
- In this Python Pattern Printing Programs video tutorial you will learn to print star '*' in A shape in detail.
To print Star Pattern in A 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 columns.Then we are using if else conditional statements that is because we are not printing stars in each row and each column we need stars in particular pattern for that we need conditions.here we are using logical and logical or operators.
If you are using Python 2 then if you write this code you will get error because in python 2 print is not a function and also we cant use end there so you need to use print as statement and instead of end you need to use coma (,) at the end of print statement to get the same output.
in python 3 you write print like this:
print("*',end="")
in python 2 you need to write:
print "*",
For more free tutorials on computer programming
/ amulsacademy
AmulsAcademy
Amazing explanation... now I can print entire alphabet (A - Z)❤️❤️
Glad to hear that :)
Bina dekhe kar logi bas logic apply kiya hai what about time complexity
Nicely explained.. Btw I slightly modified the code that has generated the same output.
In the "If" condition instead of using (col == 0 or col == 4) we can use (col % 4 == 0)
And in the second part of the "If statement" instead of using
(col > 0 and col < 4) we can use (col % 4 ! = 0).
This is just to simplify the code to make it short and sweet..btw your teaching methods are amazing.
we did the same way. :)
Such a great idea
Hands down, the best printing tutorial I have ever seen! Love Amulya's Academy!
Wow, thank you! :)
The only and much
osm mam. pure youtube pe keval hi esh logic ko mjhe smjha payi...
Thanks to this video my understanding of nested loops got better,the best explaination ive seen
Amulya's Academy I have watched many tutorial (not just python but other study material as well) but your tutorial by far is one of the best in the youtube history. Your tutorial is a boon to youtube learners. The way every step is explained makes it easy to understand even for a layman. Expecting more videos like this . Also I would appreciate if you can help me with pascal pattern program as i couldn't find in your videos . Keep rocking :-)
Thank you so much :)
I will upload pascal's triangle soon {with in a week}
Keep learning :)
@@AmulsAcademy Thanks :-)
ua-cam.com/video/5v_0Gc1Sh8s/v-deo.html this onee
The tutorials are very nice and explained very well with great examples and clear logic. Best tutorials for lockdown period.
Thank you so much :)
Thanks to this video my understanding of nested loops got better. This is such an amazing well explained video.
for row in range(7):
for col in range(5):
if ((col==0 or col==4) and row!=0)or ((row==0 or row==3) and (col0)):
print("*",end="")
else:
print(end=" ")
print()
Excellent Explanation don't skip and don't miss.
Har log aapka voice and aapka tutorial aapka different style Bata de but aap kaise sikhen kuchh nahin puchega..... vahi main puchunga how did you learn Amulya (Speed) ji.... First time I am saying you video I'm writing in my book how to learn python language thanks for your videos posting and uploading your new python videos 💐💐💐
It took me so many times to understand this tutorial so hopefully that has increased your viewer count hahaha. But now i can understand clearly and i am confident enough to apply to any pattern thankyou.
one of the best videos to learn the concepts of nested loops and pattern
you r better than my professeurs n my teachers ..thank u
Haha…thank you 😊
@@AmulsAcademy keep going please we need ur lessons
It is working....Thanks @AmulsAcademy for such wonderful videos. Keep making such informative stuff.
It's my pleasure :)
Ty u have explained vey nicely that I am able to make programs by myself ty very much
I came here from codewithharry 💜😊
Best explanation 😍🎉
Thank you for your video. What I don’t understand is how does the program know that the first for loop is for rows and the second for loop is for columns? Could you please explain?
Program does not know that the first for loop is for row, it will treat that as outer for loop.
It will work based on the condition.
:)
ua-cam.com/video/5v_0Gc1Sh8s/v-deo.html aaa
Excellent Explanation!!! Nice videos, please make more ... thanks so much!!!👍
Amuls Academy mam u are awesome i m very thankful of u...and or operator mein mam agr hum (col==0 or col==2) then it will print only stars on col_0 beacuse its first condition is true and it will not check second condition so how it prints star on col_2
Thank you:)
when column is 0 then,
in the condition (col==0 or col==2) , col=0 true so, it will print stars in column 0.
when col=2 , in the condition (col==0 or col==4) col=0 fails then it will check col=2 it is true so it will print stars in column 2.
:)
Your teaching style is good.
Thank you:)
Great future ahead madam... awesome explanation 👌..
Thanks a lot :)
i love the way u say "python". Its like pyton 😂😂😂😂😂😂😂
Third is teard 😂😂
ua-cam.com/video/5v_0Gc1Sh8s/v-deo.html sdv
Thankyou so much for the explaination!
for i in range(7):
for j in range(5):
if ((j==0 or j==4) and i!=0) or ((i==0 or i==3) and (j>0 and j
I love you, this is really helpful. Keep it up :)
Thank you:)
Python programing android application ka link bhejo
best video I ever have seen
Thank you :)
ua-cam.com/video/5v_0Gc1Sh8s/v-deo.html
ua-cam.com/video/5v_0Gc1Sh8s/v-deo.html here you can
Thanks maam for your precious explaination!!
Can you please also help us to write integers(1,2,3) in steric form?
ur voice is outstanding........
I see only few patterns and I make 26 letters easily, thanks mam. 👍
Welcome 😊
Hello Amulya we can write our name in the program......??
Yes we can :)
good explanation mam, appreciating 👍👍👍
Thank you:)
Really appreciate your efforts and believe me you are such a gem glad to find your channel
will u also explain how to choose "or" and "and" inside if condition? I'm a lot confused there several times. Could u make another short video for that amulya?plss
Ok i will try :)
@@AmulsAcademy it'll be so glad if u make one😇
ua-cam.com/video/5v_0Gc1Sh8s/v-deo.html dsv
Hi... Thank you so much for such a wonderful explanation!!!!
You got a new subscriber
really Mam, you have made everything so simple, awesome teacher you are
Mam u r great thanku for making such videos to help us thnku mam😍😍😍😍
Thank you :)
u just saved my life thanks
My pleasure :)
How
Madam how can I we put different letters printed with symbols like * side by side so that they would look like a name
Mam the code is not working the
Error type is bool is not callable
Hi Amulya,
Are you running any institution? If yes, let me know I would like to join in your institution to gain more advanced knowledge on python and the same way on data structures & algorithms..
No :)
great Videos....pls explain how to print space in row also...
Mam i tried to print this pattern but
the output is little bit different, in row== 0 or row==3 the condition ( col >0 and col
i think problem is with space
give me the full program.
:)
@@AmulsAcademy The full program should be like this :
for row in range(7):
for col in range(5):
if ((col==0 or col==4) and row!=0) or (row==3 and col>0 and col0 and col
the code is working! thank you
My Pleasure :)
Gracias por el tutorial, muy bien explicado.
Mam, can I print any name using this method..
Yes i will give you the video link :)
ua-cam.com/video/Nz08Oo76zIQ/v-deo.html
ua-cam.com/video/DOXQn_1aBrY/v-deo.html
ua-cam.com/video/5v_0Gc1Sh8s/v-deo.html yess
I WAS JUST AMAZED BCOZ IT RUNS 😎😎
n = int (input ("Enter number of rows "))
for i in range (n):
for j in range(n//2):
if (i == 0 or i == n//2) or (j == 0 or j == n//2-1):
print ("A", end = "")
else:
print (" ", end = "")
print ()
That is not working 😣
Wow... Ur great madam..
Thanks a lot :)
ua-cam.com/video/5v_0Gc1Sh8s/v-deo.html yes
Thank you for the video 💕
Superb mam but i Want to write my ajay as you wrote A please help me how can i do it
mam is there any anotherway for if condition
You can change if condition based on your requirements :)
Mam
Will you teach me
What you want to learn ?
Same all pattern. using in another method like simple and easy way
I'm getting error.. Output is printing like this.
* * * * *
* *
* *
* * * * *
* *
* *
* *
* *
Please help me out.
Check the condition properly :)
Hey mam can u make a video on logic that will help to draw any pattern in python?
I will try :)
ua-cam.com/video/5v_0Gc1Sh8s/v-deo.html suree
Mam and ki jgaah pe agr or daale to hi program run ho ta hai nhi to nhi ho rhaa
You won't get proper output :)
In row (0) and col (0) i get one more star. Please correct my mistake.
for row in range(7):
for col in range(5):
if ((col==0 or col==4 and row!=0)) or ((row==0 or row==3) and (col>0 and col
for row in range(7):
for col in range(5):
if ((col==0 or col==4) and row!=0) or ((row==0 or row==3) and (col>0 and col
yes!!! i got the correct output. Thank you so much
print ("*",end " ")
else
print(end= " ") # give two space here then your result will be same
no need of col>0 and col
Which version is it mam
Nice teaching
Thank you :)
Can u please tell me...hiw to write a and B in same line...please
Video on That is coming soon :)
hi i wt to make the strar shape not go down and draw the letter i what to put it on vertical
You want to write STAR like this right?
1. write down the alphabets on a paper.
2. all alphabet should contain same rows.
3. write down the condition in which row and column you want star.
Example:
This code will print NO.
for i in range(5):
for j in range(10):
if j==0 or j==4 or j==6 or j==9 or (i==j and j5):
print("*",end="")
else:
print(end=" ")
print()
:)
Mam I had put the same code on my laptop.. Output has arrived but the result is different from Ur pattern..
Give me the program please i will check :)
Strl =""
For ln in range(5):
For col in range(3):
If (ln==0 and (col>0 and col
for me it is showing invalid syntax for print("*",end=" ") can u explain why
If you are using python 2 this will show you error.
in python 2 use
print "*",
:)
@@AmulsAcademy thank you for this.I just wasted plenty of time on this for the correct syntax in version 2.7
ua-cam.com/video/5v_0Gc1Sh8s/v-deo.html py2
nice tuto bro, thank you!
My pleasure:)
Bro??? She is a lady...
She is not bro lmao
ma'am you are great 🤘🔥
Thanks a lot 😊
Very nice.. code for printing D and N please..
D Shape:
ua-cam.com/video/WHritdVRkTw/v-deo.html
N shape:
ua-cam.com/video/IhowMjiNPdk/v-deo.html
Mam i m enjoying learing python❤please keep it up its really very helpful for us❤❤
Thank you :)
Thank you ma'am 🙏
if ((column==0 or column==4) or ((row==0 or row==3) and (column>0 and column
Same Mee tooo
Remove the extra bracket
(column==0 or column==4)
github.com/Dushmanta/Python/blob/master/starA.py
Mam plz can u give a lecture on python List,Tuple and Dictionary plz plz plz plz plz plz plz plz
I did many videos on list tuple and dictionary please search and watch :)
clear explanation.....
Ex. Can you help me?
i'm error: there's an error in your program invalid syntax
for row in range(0,7):
for col in range(0,5):
if ((col==0 or col ==4) and row!=0) or ((row==0 or row ==3)and( col>0 and col
Are you using python 2?
then you will get error because in python 2 is just a statement.
you try this:
for row in range(0,7):
for col in range(0,5):
if ((col==0 or col ==4) and row!=0) or ((row==0 or row ==3)and( col>0 and col
yeah, thank you Amuls academy.
how to work else part because condition is not wrong and how else part space work please tell the full program working line by line
hey i got that perfect A just changed the Font Style.........
Madam I want print the the alphabets two at once like UR can give programm for that
I will upload a video on that soon :)
Not work for me :(
for row in range(7):
for col in range(5):
if((col==0 or col==4) and row!=0) or ((row==0 or row==3) and (col>0 and col
in the else part take end =" "...(space).
or write
else:
print(" ",end"")
About and or:
or :
we want to print star when anyone of the condition is true.
in the case of col==0 or col==4,
when running the for loops, initially col becomes 0 that time i want to print star in that place, later col becomes 2, 3 next 4,
when it becomes 4 we want to print star in that column.
if i take and in this condition,
col==0 and col==4
that means to print star both this condition need to be true, that is impossible.
column can't be 0 and 4 at a time.
and:
we want to print star when both the condition is true.
(col==0 or col==4) and row!=0)
here we want star in column0 column4 in every row except row0.
:)
@@AmulsAcademy wow, thank u for replay. And clear cut explanation.
Let me know when u teach python with Django tutorials.
Nice explanation with such a sweet voice
Thanks a lot 😊
ua-cam.com/video/5v_0Gc1Sh8s/v-deo.html yaa
Write python program to print the pattern of A using loop and every time user should have choice, he wants to print the pattern again or not? If user don’t want to print the patter then he will press particular character (like - n) to stop this process.
You can use while loop for that :)
@@AmulsAcademy can u tell me my python vrsion is 3 but still invalid syntax problem there also I had written all your coding exactly like that you show in your video can u plz tell me what can I do?
i m using thoonny as well as
mam can do this program using variable
You mean to take user input?
n = int(input("rows:"))
mid = int(n/2)
for i in range(n):
for j in range(5):
if (i==0 and (j>0 and j
Ma'am Same code
I put on my laptop
But result is not match
What is the difference ?
Can u show me mirror work
how to work else part because condition is not wrong and how else part space work
how can i print the pattern A,B,C at a line please one example upload mam
Ok i will do that :)
Could you please explain end" "
how to print above pattern with space in 5th column in all rows?
which pattern you want?
Can you give me the output?
'A' pattern.you printed '*' in columns 0,1,2,3 and 4.for suppose consider there is 5th column and the whole column should be printed with space.
I think you want same output (as in video) ,when column is equal to 6.
for row in range(7):
for col in range(6):
if (row==0 or row==3) and (col>0 and col
Thank you.got it.
Mam in my program the stars are coming in one line so please help me
Use print() outside the inner for loop :)
ua-cam.com/video/5v_0Gc1Sh8s/v-deo.html jklm/
Actually I wrote the source code in my idle and the star pyramid is not printing but the the space is coming to say it clearly my stars are not printing even thought blank spaces are coming.
Rows!=0 is for what function
don't want to print star in row 0.
:)
mam and or operator kase lgate ho khi pr and khi pr or...smjh ni aa rha...and or ka
we use "and" when we need both the condition to be true
for example:
imagine that i want to print stars in row 0 every column except col 0
col_0 col_1 col_2 col_3
row 0 * * *
so i will write condition like this:
if row==0 and col!=0
so it will print stars at: row 0 col 1
row 0 col 2
row 0 col 3
it won't print star at row 0 col 0
in "or" if any one condition is true whole expression becomes true:
in the above example if i use "or" instead of "and"
then it will print stars in every column. ( row ==0 or col!=0)
because when row ==0 condition becomes true it won't check next condition that is col!=0 it will directly print star.
example for or:
if i want to print stars in col 0 and col=2 in each row then i will use "or"
col_0 col_1 col_2 Col_3
row_0 * *
row_1 * *
row_2 * *
so here i will write col==0 or col==2
if col value is 0 print star
or if col is 2 print star.
:)
Amuls Academy mam u are awesome i m very thankful of u...and or operator mein mam agr hum (col==0 or col==2) then it will print only stars on col_0 beacuse its first condition is true and it will not check second condition so how it prints star on col_2
Amuls Academy mam pls btado pls pls pls
Iam Irfan iam doing BE CSE 1 st year I used ur method to print the pattern but they didn't award any marks and they said this is not the correct format
I think they asked general program, this program is for particular row and column .
I have to print my name CHARLES in a pattern program, can you help?
I will try to upload a video on that soon :)
Good
Thank you :)
Voiceeeeeee 😍😍😍
simp
Please make a tutorial about import.turtle printing letter A-Z
Ok i will try :)
Write a program to input a digit and print it in words. (Python)
write a python program to read a string of roman letters convert it to upper case
i need code for this
Gentile boy you are ,thank you for your support
In printf("*",end="");...................end not works in c language ...........it said that it is undefined function .........plzzz solve my problem ..
in c, it should be printf("*);
how to make pattern with multi letter? ex. CASA
Video link:
ua-cam.com/video/Nz08Oo76zIQ/v-deo.html
ua-cam.com/video/DOXQn_1aBrY/v-deo.html
how to write several letters? in one program?
I made a video on this, will upload it soon :)