Thanks....everytime.....for your every videos..as it always helps me a lot to deal with typical pythonn programs.......other teachers make it so complicated that it becomes very tough for me as a begginer....but you not only just write the program...but also you explain us using diagrams...and etc...etc...etc...you are awesome
For printing odd no of rows in this pattern go through this n = int(input('enter a no odd: ')) tot = n//2 for row in range(n): for col in range(n): if (row+col)==tot or (col-row)==tot or (row-col)==tot or (row+col)==tot*3: print('*',end=' ') else: print(end=' ') print()
Telling from bottom of my heart ❤️ You are really amazing The way of explanation is like awesome no words to describe you really hatsoff to you TQ so much Keep posting don't stop ur videos at any situation once again TQ so much
n = int(input("Enter the number of row (odd) : ")) m = (n+1)/2 for r in range(1,n+1): for c in range(1,n+1): if (c+r==m+1 or c-r == m-1 or r-c==m-1 or c+r==m+n): print("*",end="") else: print(end=" ") print() at last success
def pattern (n): for i in range(n): for j in range(n): if i+j==(n-1)/2 or j-i==(n-1)/2 or i-j==(n-1)/2 or i+j==(3*(n-1))/2: print('*',end='') else: print(end=' ') print(' ') pattern(11)
we can also write it as for n terms as n=int(input("Enter a no")) a=n-1 a=a/2 for i in range(n): for j in range(n): if i+j==a or j-i==a or i-j==a or i+j==a*3: print("*",end="") else: print(end=" ") print()
@@vipinsingh8706 n=int(input('Enter the number')) m=n-n//2 for i in range(1,n+1): for j in range(1,n+1): if i+j==m+1 or j-i==m-1 or i+j==n+m or i-j==n-m: print('*',end="") else: print(end=' ') print()
for row in range(5): for col in range(5): if row+col==2 or col-row==2 or row-col==2 or row+col==6: print("*",end=" '') else: print(" ",end=" ") print()
for row in range(5): for col in range(5): if row+col==2 or col-row==2 or row-col==2 or row+col==6: print("*",end=" ") else: print(" ",end=" ") print() It is working properly :)
If you want to take input for this shape use this: num = int(input()) for row in range(num): for col in range(num): if row+col==(num-1)/2 or col-row==(num-1)/2 or row-col==(num-1)/2 or row+col == 3*(num-1)/2: print("*", end="") else: print(" ", end="") print()
Hey amulya can you tell why short circuit evaluation can't be used here? I see you were taking stars individually but in your previous videos. You didn't take it like that
GENERAL SOLUTION FOR ANY NUMBER OF ROWS: n=int(input("Enter number of rows: ")) a=n//2 for row in range(n): for col in range(n): if row+col==a or row-col==a or col-row==a or row+col==(n-1+a): print("*",end='') else: print(end=' ') print()
n=int(input('Enter the number')) m=n-n//2 for i in range(1,n+1): for j in range(1,n+1): if i+j==m+1 or j-i==m-1 or i+j==n+m or i-j==n-m: print('*',end="") else: print(end=' ') print()
found a simple way to generalize the code: x = #any odd integer for row in range(x): for col in range(x): if row + col == x // 2 or col - row == x // 2 or row - col == x // 2 or row + col == (x // 2) * 3: print("*", end = "") else: print(end = " ")
print() EXPLANATION BELOW - #code for sized 5 diamond for row in range(5): for col in range(5): if row + col == 2 or col - row == 2 or row - col == 2 or row + col == 6: print("*", end = "") else: print(end = " ")
print() #code for sized 7 diamond for row in range(7): for col in range(7): if row + col == 3 or col - row == 3 or row - col == 3 or row + col == 9: print("*", end = "") else: print(end = " ")
print() If you look at the similarities between both codes. the first 3 conditions are always the same number, while the 4th condition is always 3 times the value of the first 3 conditions. So let's take the size of the diamond to be x and condition 1, 2, and 3 to be y. Since we know condition 4 is always 3 times the value of the first 3 conditions, we can call it y * 3. When x = 5, y = 2, and y * 3 = 6. When x = 7, y = 3, and y * 3 = 9. Now to figure out the correlation between x and y. If you take x // 2, the answer will always be y: 5 // 2 == 2 7 // 3 == 2 so y * 3 will then be (5 // 2) * 3 = 6 and (7 // 2) * 3 = 9. Hope this helps!
This will work for odd number rows. n = int(input("rows:")) mid = n//2 for i in range(n): for j in range(n): if i+j==mid or i-j==mid or j-i==mid or i+j==n+mid-1: print("*",end="") else: print(" ",end="") print()
#printing rambus shaped stars num=int(input("enter the number of rows:")) for row in range(1,num+1): for col in range(1,num+1): if row+col==num-1 or col-row==num-3 or row-col==num-3 or row+col==num+3: print("*",end=" ") else: print(" ",end=" ") print()
Mam I have written same code that you have told bt this code did not make a dimond, it only makes a straight line , mam plzz tell me how I can make it, I loved your way of teaching so I want that you guide me that what I can do
#for user input n==1000 n=int(input()) for i in range(n*2): for j in range(n*2-1):#col in this 0 to 6 m=((n*2-1)//2) k=m*3 if (i+j==m) or (j-i==m) or (i-j==m and j(n-1)) : print("*",end="") else: print(" ",end="") print()
num=int(input("enter the number of rows:")) for row in range(1,num+1): for col in range(1,num+1): if row+col==num-1 or col-row==num-3 or row-col==num-3 or row+col==num+3: print("*",end=" ") else: print(" ",end=" ") print()
1. Take input { number of rows } store it in a variable It is better to take odd number of row because we can’t print this pattern for even number of rows. 2. for loop for n row 3. Inside that take for loop for n column 4. Use if condition to print star 5. Else block to print space 6. Print function outside insert loop. n = int(input(“rows:”)) mid = n//2 for i in range(n): for j in range(n): if i+j==mid or j-i==mid or i-j==mid or i+j==n+mid-1: print("*",end="") else: print(end=" ") print()
for odd inputs: n = int(input("rows:")) k = n//2 for i in range(n): for j in range(n): if i+j==k or i-j==k or j-i==k or i+j==n+(k-1): print("*",end="") else: print(" ",end="") print() :)
@King Shah 673 for user input n=int(input()) for i in range(n*2): for j in range(n*2-1):#col in this 0 to 6 m=((n*2-1)//2) k=m*3 if (i+j==m) or (j-i==m) or (i-j==m and j(n-1)) : print("*",end="") else: print(" ",end="") print()
for n number the code will be def fun(n): for i in range(0,n): for j in range(0,n): if i+j==n//2 or i-j==n//2 or j-i==n//2 or i+j==n+1: print("*",end="") else: print(end=" ") print() fun(5)
Hi madam I had a doubt range is nothing but how many iterations loop is going to run right how we are supposed to add or compare those iterations can anyone explain
#printing rambus shaped stars num=int(input("enter the number of rows:")) for row in range(1,num+1): for col in range(1,num+1): if row+col==2 and row-col==2: print("*",end=" ") print()
Why it is not working For row in range (5): For col in range(5): If row+col==2 or row+col==6 or row+col==4: Print ("*" , end = " ") Else : Print( end = " ") Print ()
i already uploaded videos on half diamond or we can call it as pyramid shape th-cam.com/video/pg7i7FPUJds/w-d-xo.html th-cam.com/video/k_B-5Aad7EU/w-d-xo.html For hollow you can try by yourself . if you need any help you can ask me:)
It does not work for 10x10 though. I applied the pattern of your formula using the 10x10 but I cant seem to make a proper diamond. May I ask how would you do it? Or does this only work with odd numbers?
Hi we can't write proper diamond for even row and column we want single star in first row, but where to print that, in which column ? Because of the even number we can't find out the middle number. If you give me the output i will try to write the code:)
Amuls Academy actually I have the problem wrong. What I mean by 10x10 is the output should be: ********** ********** ********** ********** ********** ********** ********** ********** ********** ********** I'm planning to make a diamond cut shape inside. So basically the inner diamond has no asterisks while the outer diamond has. Its like a cookie cutter, only the shape it makes is diamond and it goes by a 10x10 matrix
We need common result when we perform some operation on row and column numbers, so do trial and error. write down the pattern add the row and column and see whether you will get common result form all the row and column combination if not do another operation .
@@AmulsAcademy Thank you ... i get it for row in range(7): for col in range(7): if row+col==3: print("*",end="") elif col-row==3: print("*",end="") elif row-col==3: print("*",end="") elif row+col==9: print("*",end="") else: print(end=" ") print() i was curious so i used elif instead of or operator ... it has the same output :D - Thank You
Try this:) n=int(input("enter the odd number:")) num = (n-1)/2 for row in range(n): for col in range(n): if row+col==num or col-row==num or row-col==num or row+col==n+num-1: print("*",end="") else: print(end=" ") print()
Amuls Academy n= int(input("# rows:")) a=((n-1)/2) if not (n%2==1): print ("please enter an odd value: ") continue for row in range(n): for col in range(n): if (row+col==a) or (col-row==a) or (row-col==a) or (row+col==a*3): print ("*", end="") else: print (end=" ") print()
Program for dynamic design of above given pattern. n=int(input("Enter rows: ")) for row in range(0,n): for col in range(0,n): if (row+col==n//2)or (row-col==((n-1)/2)) or (col-row==((n-1)/2))or ((row+col==(n+(n-1)/2)-1)): print("*",end="") else: print(end=" ") print() Please try if it is an error then reply me
code: for row in range(5): for col in range(5): if row+col==2 or col-row==2 or row-col==2 or row+col==6: print('*', end="") else: print(end=" ") print() #thank me later
Thanks....everytime.....for your every videos..as it always helps me a lot to deal with typical pythonn programs.......other teachers make it so complicated that it becomes very tough for me as a begginer....but you not only just write the program...but also you explain us using diagrams...and etc...etc...etc...you are awesome
Thank you :)
the way she teaches all these things is so simple and easy.
Thank you :}
For printing odd no of rows in this pattern go through this
n = int(input('enter a no odd: '))
tot = n//2
for row in range(n):
for col in range(n):
if (row+col)==tot or (col-row)==tot or (row-col)==tot or (row+col)==tot*3:
print('*',end=' ')
else:
print(end=' ')
print()
its working,
else:
print(" ",end="") Did this as per your suggestion
Thank u so much u resolve all my problems in computer science now i can say that i can make program😊😊
Pleasure :)
Aree uncle tough hai😃
Telling from bottom of my heart ❤️
You are really amazing
The way of explanation is like awesome
no words to describe you really hatsoff to you TQ so much
Keep posting don't stop ur videos at any situation once again TQ so much
Thank you so much 😊❤️
I think This Row And Column matrix output diagram is The Best Way to Achieve the output and realize about code
n = int(input("Enter the number of row (odd) : "))
m = (n+1)/2
for r in range(1,n+1):
for c in range(1,n+1):
if (c+r==m+1 or c-r == m-1 or r-c==m-1 or c+r==m+n):
print("*",end="")
else:
print(end=" ")
print()
at last success
good job bro
def pattern (n):
for i in range(n):
for j in range(n):
if i+j==(n-1)/2 or j-i==(n-1)/2 or i-j==(n-1)/2 or i+j==(3*(n-1))/2:
print('*',end='')
else:
print(end=' ')
print('
')
pattern(11)
Ma’am you’re amazing!!
I love you ❤️
Thank you :)
Its working but what should the program be if I want to take the row and column from user
You need to change if conditions :)
@@AmulsAcademy mam please can you write the code for that
we can also write it as for n terms as
n=int(input("Enter a no"))
a=n-1
a=a/2
for i in range(n):
for j in range(n):
if i+j==a or j-i==a or i-j==a or i+j==a*3:
print("*",end="")
else:
print(end=" ")
print()
this code is not run after 5
@@vipinsingh8706
n=int(input('Enter the number'))
m=n-n//2
for i in range(1,n+1):
for j in range(1,n+1):
if i+j==m+1 or j-i==m-1 or i+j==n+m or i-j==n-m:
print('*',end="")
else:
print(end=' ')
print()
Medamji u really awesome teaching I like it
Thank you:)
for row in range(5):
for col in range(5):
if row+col==2 or col-row==2 or row-col==2 or row+col==6:
print("*",end=" '')
else:
print(" ",end=" ")
print()
But output is
*
* *
* *
* *
*
for row in range(5):
for col in range(5):
if row+col==2 or col-row==2 or row-col==2 or row+col==6:
print("*",end=" ")
else:
print(" ",end=" ")
print()
It is working properly :)
It is printing like as follows in 3.7 python:
*
**
**
**
*.
What is the solution for this?
Please reply amulya..
I think you missed else part.
Please do check:)
If not give me the program:)
You print (" ",end=' ')
just give space in end varialablr like end=" "
Thank you sooo much for this tutorial!!!
Pleasure :)
can you upload some series programs like sum of different terms
number divided by its factorial and then added up
If you want to take input for this shape use this:
num = int(input())
for row in range(num):
for col in range(num):
if row+col==(num-1)/2 or col-row==(num-1)/2 or row-col==(num-1)/2 or row+col == 3*(num-1)/2:
print("*", end="")
else:
print(" ", end="")
print()
this code is not working for input value 10
Hey amulya can you tell why short circuit evaluation can't be used here? I see you were taking stars individually but in your previous videos. You didn't take it like that
You can write it in different ways 😊
thank you! I learned from this!
GENERAL SOLUTION FOR ANY NUMBER OF ROWS:
n=int(input("Enter number of rows: "))
a=n//2
for row in range(n):
for col in range(n):
if row+col==a or row-col==a or col-row==a or row+col==(n-1+a):
print("*",end='')
else:
print(end=' ')
print()
Any suggestions are welcomed...
superb explanation
Thank you :)
I am using python 3.9 ,what to use print statement at the end ... I didn't get result, can you please help me out
n=int(input('Enter the number'))
m=n-n//2
for i in range(1,n+1):
for j in range(1,n+1):
if i+j==m+1 or j-i==m-1 or i+j==n+m or i-j==n-m:
print('*',end="")
else:
print(end=' ')
print()
For nxn square
Good work continue....do you upload filehandling lecture?
Thank you :)
Yes, already uploaded few videos on that.
:)
Amuls Academy i mean vast this language talk about how to use in pygame
If want to print no rows 5 Or 3 Then out is not coming correct please tell me
found a simple way to generalize the code:
x = #any odd integer
for row in range(x):
for col in range(x):
if row + col == x // 2 or col - row == x // 2 or row - col == x // 2 or row + col == (x // 2) * 3:
print("*", end = "")
else:
print(end = " ")
print()
EXPLANATION BELOW -
#code for sized 5 diamond
for row in range(5):
for col in range(5):
if row + col == 2 or col - row == 2 or row - col == 2 or row + col == 6:
print("*", end = "")
else:
print(end = " ")
print()
#code for sized 7 diamond
for row in range(7):
for col in range(7):
if row + col == 3 or col - row == 3 or row - col == 3 or row + col == 9:
print("*", end = "")
else:
print(end = " ")
print()
If you look at the similarities between both codes. the first 3 conditions are always the same number, while the 4th condition is always 3 times the value of the first 3 conditions.
So let's take the size of the diamond to be x and condition 1, 2, and 3 to be y. Since we know condition 4 is always 3 times the value of the first 3 conditions, we can call it y * 3.
When x = 5, y = 2, and y * 3 = 6.
When x = 7, y = 3, and y * 3 = 9.
Now to figure out the correlation between x and y.
If you take x // 2, the answer will always be y:
5 // 2 == 2
7 // 3 == 2
so y * 3 will then be (5 // 2) * 3 = 6 and (7 // 2) * 3 = 9.
Hope this helps!
@amulya's academy how can we write this program of general purpose!!!!!
This will work for odd number rows.
n = int(input("rows:"))
mid = n//2
for i in range(n):
for j in range(n):
if i+j==mid or i-j==mid or j-i==mid or i+j==n+mid-1:
print("*",end="")
else:
print(" ",end="")
print()
@@AmulsAcademy Is there a way it works for even AND odd??? :( Please help!!
#printing rambus shaped stars
num=int(input("enter the number of rows:"))
for row in range(1,num+1):
for col in range(1,num+1):
if row+col==num-1 or col-row==num-3 or row-col==num-3 or row+col==num+3:
print("*",end=" ")
else:
print(" ",end=" ")
print()
Instead of row+column=6 for row=column?it's correct mam.
Mam I have written same code that you have told bt this code did not make a dimond, it only makes a straight line , mam plzz tell me how I can make it, I loved your way of teaching so I want that you guide me that what I can do
How the user enter N number than hollow pattern
mam how can we print stars for different input not for 4 like dynamic input other values like 5,6. this method don't work
what if n is given by user?
how the if condition will change frequently when we give value of n?
#for user input n==1000
n=int(input())
for i in range(n*2):
for j in range(n*2-1):#col in this 0 to 6
m=((n*2-1)//2)
k=m*3
if (i+j==m) or (j-i==m) or (i-j==m and j(n-1)) :
print("*",end="")
else:
print(" ",end="")
print()
num=int(input("enter the number of rows:"))
for row in range(1,num+1):
for col in range(1,num+1):
if row+col==num-1 or col-row==num-3 or row-col==num-3 or row+col==num+3:
print("*",end=" ")
else:
print(" ",end=" ")
print()
@@anilmacharla6939 i tried but it is not working
What if we want stars in n Number of rows madam.please explain?
1. Take input { number of rows } store it in a variable
It is better to take odd number of row because we can’t print this pattern for even number of rows.
2. for loop for n row
3. Inside that take for loop for n column
4. Use if condition to print star
5. Else block to print space
6. Print function outside insert loop.
n = int(input(“rows:”))
mid = n//2
for i in range(n):
for j in range(n):
if i+j==mid or j-i==mid or i-j==mid or i+j==n+mid-1:
print("*",end="")
else:
print(end=" ")
print()
can u write the same for test cases
Mam please work in sublime text 3 ...
mam can u write the code for it to take from input values..please mam
for odd inputs:
n = int(input("rows:"))
k = n//2
for i in range(n):
for j in range(n):
if i+j==k or i-j==k or j-i==k or i+j==n+(k-1):
print("*",end="")
else:
print(" ",end="")
print()
:)
@King Shah 673
for user input
n=int(input())
for i in range(n*2):
for j in range(n*2-1):#col in this 0 to 6
m=((n*2-1)//2)
k=m*3
if (i+j==m) or (j-i==m) or (i-j==m and j(n-1)) :
print("*",end="")
else:
print(" ",end="")
print()
what if for general coding i.e.., for input=n
when will do addition opertion and subrtarraction operatoon
Just write down pattern then find column and row value of star, then you will understand what operation you need to do 😊
How to write a program to print ' N' rows and columns
I think program should be written for generalised value.....
for n number the code will be
def fun(n):
for i in range(0,n):
for j in range(0,n):
if i+j==n//2 or i-j==n//2 or j-i==n//2 or i+j==n+1:
print("*",end="")
else:
print(end=" ")
print()
fun(5)
Hi madam I had a doubt range is nothing but how many iterations loop is going to run right how we are supposed to add or compare those iterations can anyone explain
Please can you genralise this program by taking input from the user
Yes I will try 😊
If I use range(number), how code?
#printing rambus shaped stars
num=int(input("enter the number of rows:"))
for row in range(1,num+1):
for col in range(1,num+1):
if row+col==2 and row-col==2:
print("*",end=" ")
print()
Why it is not working
For row in range (5):
For col in range(5):
If row+col==2 or row+col==6 or row+col==4:
Print ("*" , end = " ")
Else :
Print( end = " ")
Print ()
Check if Conditions again 😊
I want this code for n number of rows
Very nice
Thank you :)
Mam Please Used used input value (n)
I have tried many times but in vain
Thank u madam😊
Good. I full understand
Great!
Please make video of half diamond shape and half hollow diamond shape
i already uploaded videos on half diamond or we can call it as pyramid shape
th-cam.com/video/pg7i7FPUJds/w-d-xo.html
th-cam.com/video/k_B-5Aad7EU/w-d-xo.html
For hollow you can try by yourself .
if you need any help you can ask me:)
not only this.. every pattern series problem output shows like in that way.. plz solve my problem.. python 3.8.3 shell
in else part write print(" ",end=" ")
hope the problem will be solved in EVERY PROBLEM :)
@@ritvisachdeva8945 Thank You
nice if you explain with user given input
It does not work for 10x10 though. I applied the pattern of your formula using the 10x10 but I cant seem to make a proper diamond. May I ask how would you do it? Or does this only work with odd numbers?
Hi
we can't write proper diamond for even row and column
we want single star in first row, but where to print that, in which column ?
Because of the even number we can't find out the middle number.
If you give me the output i will try to write the code:)
Amuls Academy actually I have the problem wrong. What I mean by 10x10 is the output should be:
**********
**********
**********
**********
**********
**********
**********
**********
**********
**********
I'm planning to make a diamond cut shape inside. So basically the inner diamond has no asterisks while the outer diamond has.
Its like a cookie cutter, only the shape it makes is diamond and it goes by a 10x10 matrix
Yes got it:)
Replied on fb:)
mam this is amazing but not getting how to print using user input
The only thing i don't understand is : How do i know when to subtract or to add row and col ?
We need common result when we perform some operation on row and column numbers, so do trial and error. write down the pattern add the row and column and see whether you will get common result form all the row and column combination if not do another operation .
@@AmulsAcademy Thank you ... i get it
for row in range(7):
for col in range(7):
if row+col==3:
print("*",end="")
elif col-row==3:
print("*",end="")
elif row-col==3:
print("*",end="")
elif row+col==9:
print("*",end="")
else:
print(end=" ")
print()
i was curious so i used elif instead of or operator ... it has the same output :D - Thank You
In Python 3 it's output is
*********
Tell me
You missed print() after each row :)
Why are you hard coding? Can it not be solved using generic method?
Can u make it dynamic
Try this:)
n=int(input("enter the odd number:"))
num = (n-1)/2
for row in range(n):
for col in range(n):
if row+col==num or col-row==num or row-col==num or row+col==n+num-1:
print("*",end="")
else:
print(end=" ")
print()
Amuls Academy but it will not work for seven
For example when r+c==6 u use n+1
It will work
n+1 won't work for 7 .
Execute and check:)
Amuls Academy
n= int(input("# rows:"))
a=((n-1)/2)
if not (n%2==1):
print ("please enter an odd value: ")
continue
for row in range(n):
for col in range(n):
if (row+col==a) or (col-row==a) or (row-col==a) or (row+col==a*3):
print ("*", end="")
else:
print (end=" ")
print()
Program for dynamic design of above given pattern.
n=int(input("Enter rows: "))
for row in range(0,n):
for col in range(0,n):
if (row+col==n//2)or (row-col==((n-1)/2)) or (col-row==((n-1)/2))or ((row+col==(n+(n-1)/2)-1)):
print("*",end="")
else:
print(end=" ")
print()
Please try if it is an error then reply me
Good
I got the result like this in python 3.8.0:
*
**
**
**
**
**
*
Check the else part, you need to print space there.
else:
print(" ",end="")
:)
@@AmulsAcademy why we need to enter space there .....
pls can u explain briefly in the comments..
1A2A3
A2A3
2A3
3
Can you please tell me how to get this number pattern
It is wrong code ,I have tried to be honest ,none worked .thanks anyway
Give me the program i will make it work for you :)
It's right code .
else:
print (" ")
don't forget space .
Hi I am unable to do.. can you please draw the full diamond using alphabet a b c d e
It can't working in my PC
Download anaconda navigator and use jupyter NOTEbook
generalize the code!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
See @Jon Gall 's Code
code:
for row in range(5):
for col in range(5):
if row+col==2 or col-row==2 or row-col==2 or row+col==6:
print('*', end="")
else:
print(end=" ")
print()
#thank me later
Three😂😂
irrelevant
It can't working in my PC