Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hello, I am struggling with this python assignment. Any ideas on what the code would look like for this task? 2. Write python program to
Hello, I am struggling with this python assignment. Any ideas on what the code would look like for this task?
2. Write python program to achieve the following functionalities i. ii. Prompt the user for a file name. If you get an answer that begins with 'qorQ, go to step vii. Read the file that contains four lines with 4 integers on each line separated by a space. Each integer is a positive 1- or 2-digit number ii. Using a function, print the 16 numbers in a square as shown below iv. Determine if the numbers form a magic square. In a magic square each row, column and the two diagonals each add up to the same sum (always 34) and each value from 1 to 16 is used exactly once in the square. Each of the tests as noted in the next step (step v) should be written as a function that prints necessary messages and returns a True if all of its tests pass and False otherwise. Your main function should print "It is a magic square" only if all the tests pass. Each function should be appropriately named and have the entire square as its only input parameter. v. Print whether or not it is a magic square. If it is not, print all of the reasons found: a. b. C. d. Bad row sum ,- Bad column sum Bad diagonal sum = Not every integer used exactly once vi. Loop back to step i and do this for another square vii. Print "Done
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