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.
Latihan ini adalah bagian dari kursus
Introduction to NumPy
Petunjuk latihan
- Create another 3D array called
new_game_and_solutionwith a different 2D game and 2D solution pair:new_sudoku_gameandnew_sudoku_solution.new_sudoku_gameshould appear beforenew_sudoku_solution. - Create a 4D array called
games_and_solutionsby making an array out of the two 3D arrays:game_and_solutionandnew_game_and_solution, in that order. - Print the shape of
games_and_solutions.
Latihan interaktif praktis
Cobalah latihan ini dengan menyelesaikan kode contoh berikut.
# 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(____)