Question: Lab03 - Challenge Exercise - Magic Write a function magic(square) in a program magic.py that determines whether an array of n by n integers is


Lab03 - Challenge Exercise - Magic Write a function magic(square) in a program magic.py that determines whether an array of n by n integers is a magic square. Example input $ python3 magic.py 3 816 357 4.92 Magic square The return value is one of the following statements: Magic square Not a magic square Invalid data: missing or repeated number Some tests have been added in magic_test.py. Ensure your solution passes those tests. You are not required to write your own tests. magic.py 28 Bytes C 1 2. def magic(square): pass magic_test.py 675 Bytes to Edit Web ID from magic import magic 1 2 3 4 5 6 7 UT def test_magic(): assert magic([[8, 1, 6), [3, 5, 7], [4, 9, 2]]) == 'Magic square' assert magic( [[2, 7, 6), [9, 5, 1), [4, 3, 8]]) == 'Magic square' 8 9 9 10 11 12 13 14 15 16 17 18 19 20 21 22 def test_invalid(): assert magic([[1, 1, 1), (1, 1, 1), [1, 1, 1]]) == 'Invalid data: missing or repeated number' assert magic([[1, 2], [3, 4, 5), [6, 7, 8]]) == 'Invalid data: missing or repeated number' def test_notmagic(): assert magic([[1, 2, 3), [4, 5, 6), [7, 8, 9]]) == 'Not a magic square
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
