Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Swastik pattern
#python 3.5.2 # Python3 implementation to print swastika pattern # Function to print swastika def swastika(row,col): for i in range(row): for j in range(col): # checking if i < row/2 if(i < row // 2): # checking if j<col/2 if (j < col // 2): # print '*' if j=0 if (j == 0): print("*", end = "") # else print space else: print(" ", end = " ") # check if j=col/2 elif (j == col // 2): print(" *", end = "") else: # if i=0 then first row will have '*' if (i == 0): print(" *", end = "") elif (i == row // 2): print("* ", end = "") else: # middle column and last column will # have '*' after i > row/2 if (j == col // 2 or j == col - 1): print("* ", end = "") # last row elif (i == row - 1): # last row will be have '*' if # j <= col/2 or if it is last column if (j <= col // 2 or j == col - 1): print("* ", end = "") else: print(" ", end = " ") else: print(" ", end = " ") print() # Driver code # odd number of row and column # to get perfect swastika row = 7; col = 2 # Function calling swastika(row, col)
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Yyy
Linear Regression Python
Reverse function
Rhymes child
Add missing person
self
linked_lists_2+decisions
"Hello,world!"
sensi
H
Please log in to post a comment.