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
This is me lol jjaaaabbooo
ElenaW [278]

i like your glasses uwu

6 0
3 years ago
PLEASE HELP!!!
uysha [10]
The next line is 0___________________________
3 0
3 years ago
How to install specific microsoft office 2016 aoos
Mandarinka [93]
Go onto their website and download it.
6 0
4 years ago
A _________, such as apple.com and whitehouse.gov, uniquely identifies a site and a brand on the web.
Serga [27]

A <u>domain name </u>such as apple.com and whitehouse.gov, uniquely identifies a site and a brand on the web.

What is Domain name?

This is known to be a kind of Application programming interface. The  domain name is said to be a series or a string of letters that tells more about a realm of administrative autonomy.

It  tells about authority as well as control that is found  within the Internet. Domain names are said to be used in a lot of networking contexts and therefore, A <u>domain name </u>such as apple.com and whitehouse.gov, uniquely identifies a site and a brand on the web.

Learn more about Domain name from

brainly.com/question/13153286
#SPJ1

5 0
2 years ago
Which programming term describes the various characteristics of an object, such as its size and color?
SashulF [63]

Answer:

A

Explanation:

6 0
4 years ago
Other questions:
  • Why is RAM used for temporary storage!
    6·1 answer
  • An example of live footage is when?
    10·2 answers
  • Which data type structures best for insersion/ removal - Stack, linked list, queue?
    15·1 answer
  • Hard drive access time is measured in
    11·1 answer
  • Which of the following is one way a corporation can raise money?
    14·1 answer
  • You use ddl to create, modify, and delete the ___________________________ of a database.
    6·1 answer
  • Explain paragraph layout
    10·1 answer
  • Help With Sims 4
    13·1 answer
  • What does the video say is the number-one requirement for Tour Guides?
    12·2 answers
  • Es el nombre que se le da a la<br> intersección de una columna y fila:
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!