Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
image text in transcribed
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

How To Build A Million Dollar Database

Authors: Michelle Bergquist

1st Edition

0615246842, 978-0615246840

Students also viewed these Databases questions

Question

=+differences in home- and host-country costs of living?

Answered: 1 week ago

Question

=+derived from the assignment will balance the costs?

Answered: 1 week ago