1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
coldgirl [10]
4 years ago
15

There is a simple method for constructing a magic square for any odd value of n:

Computers and Technology
1 answer:
DaniilM [7]4 years ago
3 0

Answer:

See Explaination

Explanation:

class MagicSquare():

def __init__(self,side):

self.side=side

self.two_dimension=[]

for row in range(1,side+1):

row_line=[]

for col in range(1,side+1):

row_line.append(0)

self.two_dimension.append(row_line)

def display(self):

row=0

col=int((self.side-1)/2)

for i in range(1,self.side**2+1):

self.two_dimension[row][col]=i

row-=1

col+=1

if row==-1:

row=self.side-1

if col==self.side:

col=0

if self.two_dimension[row][col]==0:

continue

else:

row+=1

if row==self.side:

row==0

for line in self.two_dimension:

for num in line:

print("{0:>3}".format(num),end=" ")

print()

def main():

for i in range(1,14,2):

square=MagicSquare(i)

square.display()

print("----------------------------------------------------")

if __name__ == '__main__':

main()

You might be interested in
Water is constantly in motion.<br> True or false
motikmotik

Answer: true

Explanation: yes water is constantly in motion

7 0
3 years ago
Need help plz with the code
kvasek [131]

Answer:

its blocked

Explanation:

4 0
3 years ago
If you save a Word file as a Web page, what type of file will it be?
Mnenie [13.5K]

Answer:

When you save a Microsoft Word document as a Web page (on the File menu, click Save as Web Page), Word automatically converts the page to HTML (Hypertext Markup Language), the language used by Web browsers to read Web pages.

Explanation:

7 0
3 years ago
What type of object is a GUI widget the user can click to select an option, and allows for any number of these objects to be sel
andre [41]

Answer:

Checkbox

Explanation:

I remember this question.

4 0
3 years ago
20.
Kazeer [188]

Answer:

Megabyte

Explanation:

Megabytes come before Gigabytes like how Gigabytes come before Terrabytes

8 0
3 years ago
Other questions:
  • Which change signaled a musical progression toward rock and roll?
    14·1 answer
  • Stacey wants to change her document to landscape view instead of portrait. Jesse wants to change the scale of his document. Whic
    5·1 answer
  • List at least five tasks a layer performs. Could one (or more) of these tasks could be performed by multiple layers?
    13·1 answer
  • Sequence encryption is a series of encryptions and decryptions between a number of systems, wherein each system in a network dec
    9·1 answer
  • A ________ is a single media file including art, sound, animation, or movies.
    9·1 answer
  • When did computer networking go beyond the walls of the firm?
    15·1 answer
  • Read the following scenario:
    10·2 answers
  • How to tell if your cell phone is being tracked tapped or monitored by spy software?
    12·1 answer
  • A combination of numbers and symbols used to express a calculation. Question 11 options: Formula Formula Bar Worksheet Workbook
    15·1 answer
  • What are web site and web page?​
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!