The fourth dimension
छोटे arrays जैसे sudoku_game_and_solution के लिए आउटपुट जाँचने का अच्छा तरीका उन्हें प्रिंट करना है, लेकिन बड़े और अधिक डाइमेंशन वाले arrays के साथ यह झंझट वाला हो जाता है. एक और अहम जाँच है array की .shape देखना.
अब, आप एक 4D array बनाएँगे जिसमें दो sudoku गेम और उनकी solutions होंगी. numpy को np के रूप में लोड किया गया है. पिछले उदाहरण में आपने जो 3D array game_and_solution बनाया था, वह उपलब्ध है, साथ ही new_sudoku_game और new_sudoku_solution भी.
यह अभ्यास पाठ्यक्रम का हिस्सा है
NumPy परिचय
अभ्यास निर्देश
- एक और 3D array
new_game_and_solutionनाम से बनाएँ, जिसमें अलग 2D गेम और 2D solution की जोड़ी हो:new_sudoku_gameऔरnew_sudoku_solution.new_sudoku_gameपहले आना चाहिए और उसके बादnew_sudoku_solution. - एक 4D array
games_and_solutionsनाम से बनाएँ, जिसे इन दो 3D arrays से बनाएँ:game_and_solutionऔरnew_game_and_solution, इसी क्रम में. games_and_solutionsकी shape प्रिंट करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# 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(____)