Categories
programare python

Vectori in Python

Crearea unui vector si afisarea elementelor lui:

# Creating an array
my_array = [1, 2, 3, 4, 5]

# Printing elements of the array
for element in my_array:
    print(element)

Inversarea elementelor vectorului

# Creating an array
my_array = [1, 2, 3, 4, 5]

# Reversing the array
my_array = my_array[::-1]

# Printing the reversed array
print(my_array)

Gasirea maximului si minimului:

# Creating an array
my_array = [5, 2, 8, 1, 9]

# Finding the maximum and minimum elements
max_element = max(my_array)
min_element = min(my_array)

# Printing the maximum and minimum elements
print("Maximum element:", max_element)
print("Minimum element:", min_element)