Nov-17-2019, 06:06 PM
Hi, I am just trying to test some code snippets that I got from a teacher in a course I am taking.
This code should work but I am getting errors:
The Python program below handles some measurement data that get stored in an array M.
Explain briefly what the program does and write down the content of M after each iteration of the outer for-loop (i.e. the loop running over “i”).
This code should work but I am getting errors:
The Python program below handles some measurement data that get stored in an array M.
Explain briefly what the program does and write down the content of M after each iteration of the outer for-loop (i.e. the loop running over “i”).
from numpy import* N=4 M=zeros(N) M[0]=2;M[1]=1;M[2]=11;M[3]=7 for i in range (0,N,1): largest=M(i) index_largest=i for j in range (i+1,N,1): if M[j]>largest: largest=M[j] index_largest=j hold_number=M[i] M[i]=M[index_largest] M[index_largest]=hold_number print (M)