-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray_printing.py
More file actions
30 lines (25 loc) · 809 Bytes
/
array_printing.py
File metadata and controls
30 lines (25 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# This program is used to print the valus as per the output
def print_patten(n):
# arr = [[1, 1, 1, 1, 1],[1, 1, 1, 1, 1],[1, 1, 1, 1, 1],[1, 1, 1, 1, 1],[1, 1, 1, 1, 1]]
# b=5
# arr = [[0]*b]*b not array
arr = [[0 for col in range(5)]for row in range(5)]
# print(arr)
for i in range(5):
for j in range(5):
if i == 0 or i ==4 or j == 0 or j == 4:
arr[i][j] = n
elif i == 1 or i == 3 or j == 1 or j == 3:
arr[i][j] = n-1
elif i == 2:
arr[i][j] = n-2
return arr
# Main
if __name__ == "__main__":
n= int(input("Enter the number to be print in patten:"))
arr = print_patten(n)
print(*arr)
# print(arr[1])
# print(arr[2])
# print(arr[3])
# print(arr[4])