In PYTHON Define a vector of integers with 5 elements Write the following functions - vector_sum Givenavector,returns the sum of all its elements - vector_prod Givenavector,returns the product of all its elements - vector_max Givenavector,returns the max value among all its elements - vector_min Givenavector,returns the min value among all its elements
In PYTHON
Define a
Write the following functions
- vector_sum
Givenavector,returns the sum of all its elements
- vector_prod
Givenavector,returns the product of all its elements
- vector_max
Givenavector,returns the max value among all its elements
- vector_min
Givenavector,returns the min value among all its elements
Algorithm of the code:
1. Create a list of numbers called vector.
2. Define a function vector_sum that takes the vector as input and returns the sum of the elements in the vector.
3. Define a function vector_prod that takes the vector as input and returns the product of the elements in the vector.
4. Define a function vector_max that takes the vector as input and returns the maximum value in the vector.
5. Define a function vector_min that takes the vector as input and returns the minimum value in the vector.
6. Print the sum, product, maximum and minimum values of the vector.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images