Numpy Quiz
10 Questions
1 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is the output of below python list code ?
list1 = [6, 7, 12, 11, 10, 9]
list2 = list1 * 2
list2[7] = list2[8] + 2
print(list2[-7:-1])

  • [9, 6, 7, 12, 11, 10]
  • [9, 6, 7, 12, 11, 10, 9]
  • [9, 6, 14, 12, 11, 10] (correct)
  • [9, 6, 9, 12, 11, 10]
  • Which of the following option will produce below output?
    list1= [5,20,7,8,1,6,12,36]
    output:
    [20, 8, 6, 36]

  • print(list1[1:7:2])
  • print(list1[0:7:2])
  • print(list1[1:8:2]) (correct)
  • print(list1[0:8:2])
  • Which of the below code contains correct syntax to create 2D array with shape of (3, 4). Assume that “np” is the alias for numpy package.

  • np.array( [ [1, 2, 5], [3,0.1], [4,1,1], [1,4,6] ] )
  • np.array( [ [1, 2, 5, 1] [3,0.1, 4] [4,1,1, 6] ] )
  • np.array( [ [1, 2, 5, 1], [3,0.1, 4], [4,1,1,6] ] ) (correct)
  • np.array( [1, 2, 5, 1], [3,0.1, 4], [4,1,1,6] )
  • What is the output of below numpy creation code ?
    x = np.array([ np.arange(3,12,2), np.arange(4,17,3) ])
    print(x)

    <p>[[ 3, 5, 7, 9, 11],[ 4, 7, 10, 13, 16]]</p> Signup and view all the answers

    Which of the below option represents the output of the code below:

    x= np.array([
    [3, 1, 0, 0],
    [3, 0, 1, 7],
    [4, 1, 2, 3],
    [2, 3, 2, 1]])
    index=1
    z = x[ [index + 1,index], [ index - 1,index] ]
    z

    <p>[4,0]</p> Signup and view all the answers

    What is the output of below code ?
    x = np.array([
    [12, 12, 7, 14, 2, 3, 4, 4, 13, 1],
    [ 7, 2, 5, 6, 14, 10, 3, 12, 7, 11],
    [ 1, 6, 9, 13, 14, 3, 10, 4, 5, 4],
    [ 2, 8, 1, 3, 7, 3, 1, 5, 7, 12]])

    <p>[ 7, 6, 3, 11 ]</p> Signup and view all the answers

    Which of the below function(s) returns the maximum element in a given numpy array x ?

    <p>x[np.argmax(x)]</p> Signup and view all the answers

    Which of the below code option throws error ?
    x = np.array([[1,0], [2,3],[1,2] ])
    y = np.array([[10,5,0], [1,0,6], [2,2,0]])

    <p>x.dot(y)</p> Signup and view all the answers

    Which of the value is a valid option for the variable “a” in-order to solve the given linear equation ?
    2x + 3y + 2z = 24
    x + 3z = 16
    x + y = 15

    a = _________________________________
    np.linalg.solve(a,b)

    <p>np.array([[2,3,2],[1,0,3],[1,1,0]])</p> Signup and view all the answers

    What is the output of below numpy arithmetic operation code ?
    x = np.array([
    [5, 7, 8],
    [10, 12, 5],
    [4, 1, 0]])
    y = np.array([2,5,3])
    print( x + y – 2)

    <p>[[ 5, 10, 9], [10, 15, 6], [ 4, 4, 1]]</p> Signup and view all the answers

    More Like This

    Master Python Lists
    3 questions

    Master Python Lists

    HolyMoldavite avatar
    HolyMoldavite
    Python Lists and Tuples
    6 questions

    Python Lists and Tuples

    AppropriateSheep avatar
    AppropriateSheep
    Use Quizgecko on...
    Browser
    Browser