View the step-by-step solution to:

Question

# <pre class="ql-syntax"><span class="hljs-comment"># Return the index of the

maximum value in the list</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">getIndexMaximum</span><span class="hljs-params">(numList)</span></span>: <span class="hljs-comment"># init the maximum</span> maximum = numList[<span class="hljs-number">0</span>] max_index = <span class="hljs-number">0</span> <span class="hljs-comment"># loop through the rest of the list</span> <span class="hljs-keyword">for</span> index <span class="hljs-keyword">in</span> range(<span class="hljs-number">1</span><span class="hljs-symbol">:len</span>(numList)-<span class="hljs-number">1</span>): <span class="hljs-comment"># get current at index</span> current = numList[index] <span class="hljs-comment"># if new max</span> <span class="hljs-keyword">if</span> current &gt; <span class="hljs-symbol">maximum:</span> <span class="hljs-comment"># reset max</span> maximum = current max_index = index <span class="hljs-keyword">return</span> maximum </pre>

Let me explain the... View the full answer

main.py
saved
N
def getIndexMaximum(numList) :
3
# init the maximum
5
maximum = numList[0]
6
max index = 0
7
8
# loop through the rest of the list
9
for index in range(0, len(numList) ) :
10
11
#...

### Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

• ### -

Study Documents

Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

Browse Documents