Run Code
|
API
|
Code Wall
|
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
Right_Align_Text
Faiha Lesson 2
lesson7 part2
PyRegFindFull
EJ2_PYTHON_20.321.212-7
If else if in 2 ways
BMO1 Q1 1994
Game3
Iam hungry
Byear