Get startedGet started for free

The fourth dimension

Printing arrays is a good way to check code output for small arrays like sudoku_game_and_solution, but it becomes unwieldy when dealing with bigger arrays and those with higher dimensions. Another important check is to look at the array's .shape.

Now, you'll create a 4D array that contains two sudoku games and their solutions. numpy is loaded as np. The game_and_solution 3D array you created in the previous example is available, along with new_sudoku_game and new_sudoku_solution.

This exercise is part of the course

Introduction to NumPy

View Course

Exercise instructions

  • Create another 3D array called new_game_and_solution with a different 2D game and 2D solution pair: new_sudoku_game and new_sudoku_solution. new_sudoku_game should appear before new_sudoku_solution.
  • Create a 4D array called games_and_solutions by making an array out of the two 3D arrays: game_and_solution and new_game_and_solution, in that order.
  • Print the shape of games_and_solutions.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Create a second 3D array of another game and its solution 
new_game_and_solution = ____

# Create a 4D array of both game and solution 3D arrays
games_and_solutions = ____

# Print the shape of your 4D array
print(____)
Edit and Run Code