Solution 1

import random


def _get_random_number_not_repeated(previous_numbers):
    while True:
        number = random.randint(0, 100)
        if number not in previous_numbers:
            return number


def random_matrix(m, n):
    used_numbers = []
    matrix = []

    for i in range(m):
        row = []
        for j in range(n):
            number = _get_random_number_not_repeated(used_numbers)
            row.append(number)
            used_numbers.append(number)
        matrix.append(row)

    return matrix

Random Numbers Matrix

Use the random module (more below) to write a function random_matrix that returns a matrix size m × n with random numbers (m is the number of rows and n is the number of columns).
The only restriction is that elements in the matrix CAN'T be repeated, they must be unique. Examples:

random_matrix(3, 2)
[
    [29, 11],
    [91, 85],
    [56, 18],
]

random_matrix(4, 4)
[
    [29, 11, 23, 90],
    [91, 85, 92, 75],
    [56, 18, 13, 47],
    [65, 99, 49, 10]
]

Random Numbers

To generate random numbers you can use the random module. It's super simple, check the following example (or try it for yourself):

import random
number = random.randint(0, 100) # A random number between 0 and 100
print(number)

Test Cases

test size 3x2 elements not repeated - Run Test

def test_size_3x2_elements_not_repeated():
    matrix = random_matrix(3, 2)

    assert len(matrix) == 3
    for row in matrix:
        assert len(row) == 2

    repeated_elements = []
    for row in matrix:
        for elem in row:
            assert elem not in repeated_elements
            repeated_elements.append(elem)

import random def random_matrix(m, n): pass