20 lines
739 B
Python
20 lines
739 B
Python
import numpy as np
|
|
# Generating a random number
|
|
random_number = np.random.rand()
|
|
print(random_number)
|
|
# Generating a random 1D array with 5 elements
|
|
random_array = np.random.rand(5)
|
|
print(random_array)
|
|
# Generating a random 2D array (matrix) of shape 4x3
|
|
random_matrix = np.random.rand(4, 3)
|
|
print(random_matrix)
|
|
|
|
# Generate a 1D array of random floats in [0, 1) with 4 elements
|
|
random_floats_array = np.random.rand(4)
|
|
# Generate a 2D array of random floats in [0, 1) of shape 3x2
|
|
random_floats_matrix = np.random.rand(3, 2)
|
|
# Generate a 2D array of random integers in [10, 21) of shape 3x2
|
|
random_integers_matrix = np.random.randint(10, 21, size=(3, 2))
|
|
print(random_floats_array)
|
|
print(random_floats_matrix)
|
|
print(random_integers_matrix) |