Using only one 2-D array (table) with equal odd sizes for its rows and columns, write a complete python program for a magic square. Use the sample output below as your basis for uniformity. Note: A magic square has its rows, columns, and diagonals sum to be ALL EQUAL in value. Input: Enter size = 3 Output: 3 x 3 magic square 8 1 6 3 5 7 4 9 2 Note: All rows, columns, and diagonal sum = 15 Try again (Y/N) Y Input: Enter size = 5 Output: 5 x 5 magic square 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9 Note: All rows, columns, and diagonal sum = 65 Try again (Y/N) N Thank you. Have a great day ahead.
Using only one 2-D array (table) with equal odd sizes for its rows and columns, write a complete python program for a magic square. Use the sample output below as your basis for uniformity.
Note: A magic square has its rows, columns, and diagonals sum to be ALL EQUAL in value.
Input: Enter size = 3
Output: 3 x 3 magic square
8 1 6
3 5 7
4 9 2
Note: All rows, columns, and diagonal sum = 15
Try again (Y/N) Y
Input: Enter size = 5
Output: 5 x 5 magic square
17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9
Note: All rows, columns, and diagonal sum = 65
Try again (Y/N) N
Thank you. Have a great day ahead.
Step by step
Solved in 2 steps with 3 images