<prompt> Write code to find the maximum value in an array2, 4, 5, 7, 1  <response>: Here is an example code written in Python to find the maximum value in an array:pythondef find_maxarr: max_val arr0 for i in range1, lenarr: if arri max_val: max_val arri return max_valinput_array 2, 4, 5, 7, 1max_value find_maxinput_arrayprintThe maximum value in the array is:, max_valueIn this code, we define a function find_max that takes an array as an input argument. Inside the function, we initialize a variable max_val with the first element of the array. Then, we iterate over the array using a for loop, and compare each element with max_val. If the current element is greater than max_val, we update the value of max_val. Finally, when the loop finishes, we return the value of max_val as the maximum value in the array. 