Question

Given the following code snippet, what will be the output when the function findMax is called with the array arr = [1, 5, 3, 9, 2]?  def findMax(arr):     max_val = arr[0]     for num in arr:         if num > max_val:             max_val = num     return max_val result = findMax([1, 5, 3, 9, 2]) print(result)

A 1
B 5
C 9
D 3
E 2
Practice Next

Relevant for Exams:

Hey! Ask a query