Write a python program that simulates a lo shu magic square using a two-dimensional list. The program should initialize a two-dimensional list with trial values. Don't ask for values as user input. Program must determine if the array is a Lo Shu Magic Square. These contain numbers 1-9 and have 3 rows and 3 columns. I want to use the following functions in the program:  drawBoard(): No return value.  Takes a two-dimensional list as input. Prints the Lo Shu Magic Square. isWinner(): Returns True when all the winning properties are satisfied. Takes a two-dimensional list as input. checkNumbers(): Returns True when the digits 1-9 exactly are used. Takes a two-dimensional list as input. checkRows(): Returns True when the sums of the rows are the same. Takes a two-dimensional list as input. checkColumns(): Returns True when the sums of the columns are the same. Takes a two-dimensional list as input. checkDiagonals(): Returns True when the sums of the diagonals are the same. Takes a two-dimensional list as input.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 9PE
icon
Related questions
Question
100%

Write a python program that simulates a lo shu magic square using a two-dimensional list. The program should initialize a two-dimensional list with trial values. Don't ask for values as user input. Program must determine if the array is a Lo Shu Magic Square. These contain numbers 1-9 and have 3 rows and 3 columns. I want to use the following functions in the program: 

drawBoard(): No return value.  Takes a two-dimensional list as input.
Prints the Lo Shu Magic Square.

isWinner(): Returns True when all the winning properties are satisfied.
Takes a two-dimensional list as input.

checkNumbers(): Returns True when the digits 1-9 exactly are used.
Takes a two-dimensional list as input.

checkRows(): Returns True when the sums of the rows are the same.
Takes a two-dimensional list as input.

checkColumns(): Returns True when the sums of the columns are the same.
Takes a two-dimensional list as input.

checkDiagonals(): Returns True when the sums of the diagonals are the same.
Takes a two-dimensional list as input. 

I will attach a picture of the code I've tried so far. 

Chapter 8 Programming Activity 8 Lists and Dictionaries
Brielle Sindt
10-20-2023
III
#CONSTANTS
#rows
#columns
#minimum
#maximum
HW 8 Lists and Dictionaries.py - /Users/Brielle 04/Desktop/HW 8 Lists and Dictionaries.py (3.11.4)
#start_index
#no_good
#PROCESS
'drawBoard 'F=int (input('[4, 9, 2, 3, 5, 7, 8, 1, 6]'))
for row in square:
print (row)
def LoShu (List2d):
if isinstance (List2d, list) and len (List2d) ==3:
List1d=sum (List2d, [])
print (Listld)
if max (Listld) >=10 or min (Listld) <=0:
print("No good")
return False
checkRows
rowlsum= List2d [0] [0] +List2d [0] [1] +List2d [0] [2]
row2sum= List2d [1] [0] +List2d [1] [1] +List2d [1] [2]
row3sum= List2d [0] [0] +List2d [0] [1] +List2d [0] [2]
checkColumns
collsum= List1d [0] +List1d [3] +List1d [6]
col2sum= List1d [1] +List1d [4] +List1d [7]
col3sum= List1d [2]+List1d [5]+List1d [8]
checkDiagonals
rightDiagonalsum= List1d [2] +List1d [4] +List1d [6]
leftDiagonalsum= List1d [0] +List1d [4] +List1d [8]
isWinner
else:
if rowlsum==row2sum==row3sum==collsum==col2sum==col3sum==right Diagonalsum==leftDiagonalsum:
print("This is a LoShu Magic Square")
print("No good")
print (LoShu (Square))
Transcribed Image Text:Chapter 8 Programming Activity 8 Lists and Dictionaries Brielle Sindt 10-20-2023 III #CONSTANTS #rows #columns #minimum #maximum HW 8 Lists and Dictionaries.py - /Users/Brielle 04/Desktop/HW 8 Lists and Dictionaries.py (3.11.4) #start_index #no_good #PROCESS 'drawBoard 'F=int (input('[4, 9, 2, 3, 5, 7, 8, 1, 6]')) for row in square: print (row) def LoShu (List2d): if isinstance (List2d, list) and len (List2d) ==3: List1d=sum (List2d, []) print (Listld) if max (Listld) >=10 or min (Listld) <=0: print("No good") return False checkRows rowlsum= List2d [0] [0] +List2d [0] [1] +List2d [0] [2] row2sum= List2d [1] [0] +List2d [1] [1] +List2d [1] [2] row3sum= List2d [0] [0] +List2d [0] [1] +List2d [0] [2] checkColumns collsum= List1d [0] +List1d [3] +List1d [6] col2sum= List1d [1] +List1d [4] +List1d [7] col3sum= List1d [2]+List1d [5]+List1d [8] checkDiagonals rightDiagonalsum= List1d [2] +List1d [4] +List1d [6] leftDiagonalsum= List1d [0] +List1d [4] +List1d [8] isWinner else: if rowlsum==row2sum==row3sum==collsum==col2sum==col3sum==right Diagonalsum==leftDiagonalsum: print("This is a LoShu Magic Square") print("No good") print (LoShu (Square))
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr