Knowee
Questions
Features
Study Tools

import numpy as npnp_marks = np.array( [23, 21, 18, 25, 12, 18, 10] )print( np_marks[ (np_marks >= 15) ] )

Question

import numpy as npnp_marks = np.array( [23, 21, 18, 25, 12, 18, 10] )print( np_marks[ (np_marks >= 15) ] )

🧐 Not the exact question you are looking for?Go ask a question

Solution

The code you provided is written in Python, specifically using the NumPy library. It creates an array of student marks and then prints out all marks that are greater than or equal to 15. Here's a step-by-step explanation:

  1. import numpy as np: This line imports the NumPy library, which is a powerful library in Python used for mathematical and logical operations on arrays. It is renamed as np for convenience.

  2. np_marks = np.array( [23, 21, 18, 25, 12, 18, 10] ): This line creates a NumPy array named np_marks containing the values 23, 21, 18, 25, 12, 18, and 10. These values could represent, for example, the marks of seven students in a test.

  3. print( np_marks[ (np_marks >= 15) ] ): This line prints out all the values in np_marks that are greater than or equal to 15. The expression (np_marks >= 15) creates a boolean mask where each element is True if the corresponding element in np_marks is greater than or equal to 15, and False otherwise. When this mask is used to index np_marks, only the elements where the mask is True are selected.

So, if you run this code, it will print out the values 23, 21, 18, 25, and 18, because these are the marks that are greater than or equal to 15.

This problem has been solved

Similar Questions

import numpy as np    b = np.array([12, 90, 380, 12, 211])    print(np.where(b>12))    c = np.array([[20, 24],[21, 23]])    print(np.where(c>20))  Output:(array([1, 2, 4]),)(array([0, 1, 1]), array([1, 0, 1]))

What is a correct syntax to print the number 8 from the array below:arr = np.array([[1,2,3,4,5], [6,7,8,9,10]])(1 Point)a) print(arr[3,0])b) print(arr[1,2])c) print(arr[7,2])d) print(arr[2,3])

Output of the below snippet: import numpy as np a=np.array([100,2,300,]) print(a[0],a[2])

age=np.array([15,17,19,20,14,21,16,19,13,20,22,23,21,16,18,19,20,15,17,18])height=np.array([156,144,180,162,152,157,154,155,151,150,158,179,126,182,183,154,159,160,172,149])Given age and height of 20 students in two different numpy arrays with name age and height (in cms). Print the age of those students whose height is above 155 cm.Print the Numpy array.

30. What does the following Python code output? import numpy as np a = np.array([[1, 2], [3, 4], [5, 6]]) print(a[:, 1])  [1, 3, 5][1, 4, 5][2, 3, 6][2, 4, 6]

1/2

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.