7 Hours course Python for pattern programs, Example Programs, Data Structures and Algorithms (3 in 1 course) out now link : www.udemy.com/course/python-for-patterns-problems-data-structures-algorithms/?referralCode=186515267189E391E366
If you like this to type of content then consider subscribing, it really helps out the channel Find more pattern programs here: th-cam.com/play/PLhBd9eXZZqGIhrPl97yOfOAI7TqJQOHRm.html
Take if condition as below,but it will work for only odd numbers such 3,5,7,9,11 ...: n = int(input()) for row in range(1,n+1): for col in range(1,n+1): if (row+col==(n+1)/2+1) or (col-row==(n+1)/2-1) or (row-col==(n+1)/2-1) or (col+row==n+(n+1)/2): print('*',end='') else: print(' ',end='') print()
n=int(input("enter row")) for i in range(1,n+1): print(' '*(n-i)+'*',end="") if i>=2: print(' '*(2*i-3)+'*',end="") print() for i in range(1,n): print(' '*(i)+'*',end="") if i
# hollow diamond n = int(input("Enter number of rows :: ")) def hollow_diamond(n): for i in range((n*2)-1): for j in range((n*2)-1): if (i+j == n-1) or (i-j == n-1) or(j-i == n-1) or (i+j == 3*(n-1)): print(" *",end="") else: print(" ",end="") print("") hollow_diamond(n) this code generate accurate output for any inputs (in numbers)
7 Hours course Python for pattern programs, Example Programs, Data Structures and Algorithms (3 in 1 course) out now link : www.udemy.com/course/python-for-patterns-problems-data-structures-algorithms/?referralCode=186515267189E391E366
If you like this to type of content then consider subscribing, it really helps out the channel
Find more pattern programs here:
th-cam.com/play/PLhBd9eXZZqGIhrPl97yOfOAI7TqJQOHRm.html
Thank you for this lesson on creating diamond pattern in an easily understandable method.
Ur video helped me, can't say how much😌
Awesome bro
What if you want the rows and columns to be n, not 7?
Please answer
Take if condition as below,but it will work for only odd numbers such 3,5,7,9,11 ...:
n = int(input())
for row in range(1,n+1):
for col in range(1,n+1):
if (row+col==(n+1)/2+1) or (col-row==(n+1)/2-1) or (row-col==(n+1)/2-1) or (col+row==n+(n+1)/2):
print('*',end='')
else:
print(' ',end='')
print()
n=int(input("enter row"))
for i in range(1,n+1):
print(' '*(n-i)+'*',end="")
if i>=2:
print(' '*(2*i-3)+'*',end="")
print()
for i in range(1,n):
print(' '*(i)+'*',end="")
if i
Its not exactly giving the correct pattern their is a issue in output can u plz check nd provide the correct one...
hello sir, i did exactly what u did but my output is this:
b
b
b
b
b
b
b
b
b
b
b
b
😘
not true for all cases
Its a customized code and is not valid for other inputs if you provide
# hollow diamond
n = int(input("Enter number of rows :: "))
def hollow_diamond(n):
for i in range((n*2)-1):
for j in range((n*2)-1):
if (i+j == n-1) or (i-j == n-1) or(j-i == n-1) or (i+j == 3*(n-1)):
print(" *",end="")
else:
print(" ",end="")
print("")
hollow_diamond(n)
this code generate accurate output for any inputs (in numbers)