Question: Write a module of utility functions called util. py for manipulating 2 - dimensional arrays of size 4 4 . ( These functions will be

Write a module of utility functions called util. py for manipulating 2-dimensional arrays of size
44.(These functions will be used in Question 3.)
The functions you need to write are as follows:
def create_grid(grid):
"""create a 4\times4 array of zeroes within grid"""
def print_grid (grid):
"""print out a 4x4 grid in 5-width columns within a box"""
def check_lost (grid):
"""return True if there are no 0 values and there are no
adjacent values that are equal; otherwise False"""
def check_won (grid):
"""return True if a value>=32 is found in the grid; otherwise
False"""
def copy_grid (grid):
"""return a copy of the given grid"""
def grid_equal (grid1, grid2):
"""check if 2 grids are equal - return boolean value"""
Version 11/09/202413:53
Note: these functions are described using docstrings.
Use the
testutil.py test program to test your functions. This program takes a single integer
input value and runs the corresponding test on your module. This is a variant of unit testing, where
test cases are written in the form of a program that tests your program. You will learn more about
unit testing in future CS courses.
Sample IO (The input from the user is shown in bold font - do not program this):
Sample IO (The input from the user is shown in bold font - do not program this):
7
True
Sample IO (The input from the user is shown in bold font - do not program this):
17
4
1616
2}
644
6416
642
Sample IO (The input from the user is shown in bold font - do not program this):
9
True
Sample IO (The input from the user is shown in bold font - do not program this):
Write a module of utility functions called util.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!