Array Jigsaw
| You can not trust code monkeys any more! You ask them to write some code but they end up giving it to you in the wrong order! Your task is to work out the correct order for the code below. | ![]() |
Following is a list of tasks you have to do using the code below
#1. Store numbers 2,8,4 in an array
#2. prints the elements of the array
#3. store 5 as the a fourth element in the array
#4. reset the second element to 6
#5. uses the elements and prints the sum and the average of the elements.
*********************************************************************************
Re-arrange the code below to do the above tasks.
print "element of my_NumArray at position ", x, "is", my_NumArray[x] while x < len(my_NumArray): my_NumArray = [2,4,8] x = x + 1 print "Sum is",sum x=0 my_NumArray.append(5) print "Average is ", sum / len(my_NumArray) sum = sum + my_NumArray[x] my_NumArray[1] = 6 sum = 0
You need to log in or create an account to submit code!












