4 of 6
Print all coordinate pairs for a 3Γ3 grid:
(0,0) (0,1) (0,2)
(1,0) (1,1) (1,2)
(2,0) (2,1) (2,2)
# Print all (row, col) pairs for a 3x3 grid for row in range(___): for col in range(___): print(f"(___,___)", end=" ") print()
Both the outer and inner loops should go from 0 to 2: range(3)
Use an f-string: f"({row},{col})" and print with end=" " to stay on the same line.
Make it work for any size grid! Ask the user for the size:
size = int(input("Grid size: ")) # Print all coordinate pairs for that size
for row in range(3): for col in range(3): print(f"({row},{col})", end=" ") print()
size = int(input("Grid size: ")) for row in range(size): for col in range(size): print(f"({row},{col})", end=" ") print()
β Standard library: heapq, collections, itertools, math, random, functools, datetime, bisect
β Functions, classes, recursion, print()
β No file system, subprocess, OS access, or network requests
β No pip install (all supported modules are pre-loaded)
β±οΈ 5 second execution time limit