create a 100x100 coordinate format matrix in python

You can create a 100x100 matrix in Python using the Numpy library. Here's how to do it:

main.py
import numpy as np

# Create a 100x100 matrix filled with zeros
matrix = np.zeros((100, 100))

# Access a specific coordinate and set its value to 1
matrix[0, 0] = 1

# Print the matrix
print(matrix)
200 chars
11 lines

This code creates a 100x100 matrix filled with zeros and stores it in the matrix variable. To access a specific coordinate in the matrix, you use the syntax matrix[row_index, column_index]. The first index represents the row number, and the second index represents the column number. In this example, we set the value of the coordinate at row 0, column 0 to 1.

You can modify the code to set the values of other coordinates, or to create a matrix filled with different values besides zeros.

related categories

gistlibby LogSnag