Question: 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]])

 def test_magic(): assert magic([[8, 1, 6], [3, 5, 7], [4, 9,

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'

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'

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 8 1 6 3 5 7 4 9 2 Magic square The return value is one of the following statements: . Magic square Not a magic square Invalid data: missing or repeated number

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!