You can download this code by clicking the button below.
This code is now available for download.
This function generates a random integer square matrix of a specified size.
Technology Stack : math, random
Code Type : Function
Code Difficulty : Intermediate
import math
import random
def generate_random_square_number(size):
"""
Generate a random square matrix of given size.
Args:
size (int): The size of the square matrix to generate.
Returns:
list: A list of lists representing the square matrix.
"""
matrix = [[random.randint(0, 100) for _ in range(size)] for _ in range(size)]
return matrix