You can download this code by clicking the button below.
This code is now available for download.
This function uses the numpy library to generate a random matrix of specified rows and columns.
Technology Stack : numpy, pandas, fire
Code Type : Python Function
Code Difficulty : Intermediate
import random
import json
import fire
import numpy as np
import pandas as pd
def generate_random_matrix(rows, cols):
"""
Generate a random matrix of given size using numpy.
"""
return np.random.rand(rows, cols)
def main():
rows = random.randint(1, 10)
cols = random.randint(1, 10)
matrix = generate_random_matrix(rows, cols)
print(matrix)
if __name__ == "__main__":
fire.Fire(main)