21 lines
520 B
Python
21 lines
520 B
Python
import numpy as np
|
|
|
|
rand_arr = np.random.randint(1,11,10)
|
|
|
|
print(rand_arr)
|
|
|
|
# https://pythonguides.com/python-program-to-print-the-smallest-element-in-an-array/
|
|
def sort():
|
|
for index in range(len(rand_arr) - 1):
|
|
min_index = index
|
|
|
|
for next_index in range(index + 1, len(rand_arr)):
|
|
|
|
if rand_arr[next_index] < rand_arr[min_index]:
|
|
min_index = next_index
|
|
|
|
|
|
rand_arr[index], rand_arr[min_index] = (rand_arr[min_index], rand_arr[index])
|
|
print(rand_arr)
|
|
|
|
sort() |