Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Required Functions You are required to write and use the following three functions in your submission: def populateSquare ( size ) : this function takes
Required Functions
You are required to write and use the following three functions in your submission:
def populateSquaresize: this function takes an integer representing the
size of the square, asks the user to enter the integer values to populate the square
and it returns the square. To simulate the square, we will use a list of lists: this is a
list in which each element is another list. Each value entered by the user can only
appear one single time in the square so no repeated values
def printSquaresquare: this function takes the filled square so the list
of lists and displays it into the screen, one row per line. This function does not
return anything.
def isMagicSquaresquare: this function takes the filled square so the list
of lists and returns a Boolean that indicates whether or not the square is magic
square as per the rules explained above.
Note: while solving this problem, you may find the need to create one or more helper
functions for example to validate user input That is fine and you can add those
functions to your program.
Program Examples
Example users input is shown in red:
Welcome to the Magic Square Game
Enter the size of your square between and :
Row
Enter a value for the square:
Enter a value for the square:
Enter a value for the square:
Row
Enter a value for the square:
Enter a value for the square:
Enter a value for the square:
Row
Enter a value for the square:
Enter a value for the square:
Enter a value for the square:
Here is your square:
This is a magic square!!
Example users input is shown in red:
Welcome to the Magic Square Game
Enter the size of your square between and :
Row
Enter a value for the square:
Enter a value for the square:
Enter a value for the square:
Row
Enter a value for the square:
Enter a value for the square:
Enter a value for the square:
Row
Enter a value for the square:
Enter a value for the square:
Enter a value for the square:
Here is your square:
This is not a magic square.
Example users input is shown in red:
Welcome to the Magic Square Game
Enter the size of your square between and :
Row
Enter a value for the square:
Enter a value for the square:
Enter a value for the square:
Enter a value for the square:
Row
Enter a value for the square:
Enter a value for the square:
Enter a value for the square:
Enter a value for the square:
Row
Enter a value for the square:
Enter a value for the square:
Enter a value for the square:
Enter a value for the square:
Row
Enter a value for the square:
Enter a value for the square:
Enter a value for the square:
Enter a value for the square:
Here is your square:
This is a magic square!!
Example users input is shown in red:
Welcome to the Magic Square Game
Enter the size of your square between and :
Value out of bounds. Please try again.
Enter the size of your square between and :
Value out of bounds. Please try again.
Enter the size of your square between and : abc
Invalid input. Please try again.
Enter the size of your square between and :
Row
Enter a value for the square:
Enter a value for the square:
Error: this value already exists in the square. Enter a different
value.
Enter a value for the square:
Error: this value already exists in the square. Enter a different
value.
Enter a value for the square:
Value out of bounds. Please try again.
Enter a value for the square:
Value out of bounds. Please try again.
Enter a value for the square: xyz
Invalid input. Please try again.
Enter a value for the square:
Enter a value for the square:
Row
Enter a value for the square:
Enter a value for the square:
Enter a value for the square:
Row
Enter a value for the square:
Enter a value for the square:
Enter a value for the square:
Here is your square:
This is not a magic square.
Example users input is shown in red:
Welcome to the Magic Square Game
Enter the size of your square between and :
Row
Enter a value for the square:
Enter a value for the square:
Enter a value for the square:
Row
Enter a value for the square:
Error: this value already exists in the square. Enter a different
value.
Enter a value for the square:
Error: this value already exists in the square. Enter a different
value.
Enter a value for the square:
Enter a value for the square:
Error: this value already exists in the square. Enter a different
value.
Enter a value for the square:
Enter a value for the square:
Row
Enter a value for the square:
Error: this value already exists in the square. Enter a different
value.
Enter a value for the square:
Enter a value for the square:
Enter a value for the square:
Here is your square:
This is not a magic square.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started