141k views
6 votes
Finish the code to search for a 7 in the array.

from array import *
myArr = array('f',[3, 5, 7.3, 10])
location = myArr.
(7)

User Akbiggs
by
4.9k points

1 Answer

10 votes

Answer:

The complete code is as follows:

from array import *

myArr = array('f',[3, 5, 7,3, 10])

location = myArr.index(7)

print(str("7")+" is at position "+str(location+1))

Step-by-step explanation:

I made corrections to the third line of the code and I added a line

This line gets the index of 7 from the array myArr using the index keyword

location = myArr.index(7)

This line prints the position of the 7 in the array

print(str("7")+" is at position "+str(location+1))

User Sagar Pudi
by
5.0k points