How to Find the Minimum and Maximum Element in an Array Using Python?

Certainly! You can find the minimum and maximum elements in an array in Python using built-in functions such as min() and max(). Here’s an example:

Sure, here is the code:

# Sample array
my_list = [10, 2, 5, 1, 8, 20]
# Find minimum and maximum elements using built-in functions
min_element = min(my_list)
max_element = max(my_list)
# Print the results
print("Minimum element:", min_element)
print("Maximum element:", max_element)

This code outputs the following:

Minimum element: 1
Maximum element: 20

Explanation:

The code defines a list `my_list` containing sample data. Then, it uses the built-in functions `min()` and `max()` to find the minimum and maximum elements in the list, respectively. Finally, it prints the results.