ICT finals Flashcards

(41 cards)

1
Q

What is Numpy?

A

A python library for numerical computing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How can you install Numpy?

A

pip install numpy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the primary object type in Numpy?

A

ndarrays

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you import Numpy in a Python script?

A

import numpy as np

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does the following code output: np.array([1, 2, 3, 4, 5])?

A

[1, 2, 3, 4, 5]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are 0-D arrays in Numpy?

A

Scalars

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are 1-D arrays also known as?

A

Vectors

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which of the following is a 2-D array?

A

np.array([[1, 2, 3], [4, 5, 6]])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How does you access the second element of the first row in a 2-D array?

A

arr[0, 1]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does negative indexing represent?

A

Accessing elements from the start

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you slice elements from index 1 to 4 in an array?

A

arr[1:4]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does arr[-3:-1] return?

A

The last three elements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the step in array slicing used for?

A

To skip elements in the array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the difference between a copy and a viewer of a Numpy array?

A

A copy owns the data, a view does not

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What will arr[0] = 42 change in a view of an array?

A

It will update only the view

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How can you iterate through each element in a 1-D Numpy array?

A

for x in arr: print(x)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What does np.ndenumerate() do?

A

Enumerates over ndarray sequence

18
Q

What is the output of print(arr[1, -1])?

A

Prints the last element of the second row

19
Q

What does arr[1:5:2] do?

A

Selects elements from index 1 to 2 with a step of 5

20
Q

How do you select elements from the second row and columns 1 to 4 in a 2-D array?

21
Q

What does the shape attribute of a Numpy array return?

A

arr.reshape(2, 6)

22
Q

How can you reshape a 1-D array with 12 elements into a 2-D array with 4 arrays, each containing 3 elements?

A

arr.reshape(4, 3)

23
Q

arr = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])

What is the original shape of the array arr?

24
Q

What will be the new shape of an array after this operation: arr.reshape(2, 3, 2)

25
If you have a 2-D array and you iterate over it, what will you get?
Each row of the array
26
What does the concatenate() function do in Numpy?
Joins a sequence of arrays along an existing axis
27
How do you join two 1-D array along the second axis using Numpy?
np.stack((arr1, arr2), axis=1)
28
walang questionnaire and no.28 pero may sagot
np.vstack()
29
What is the result of splitting an array using np.array_split(arr, 3)?
A list containing three arrays
30
How can you search for the value '4' in a NumPy array?
np.where(arr == 4)
31
What does the sort() function do in Numpy?
Orders the elements in an ascending od descending sequence
32
How do you filter an array to only include elements greater than 42?
arr[arr > 42]
33
quiz_scores = np.array([[85, 90, 92], [88, 82, 95], [75, 78, 80], ]) What is the shape of the quiz_scores array before reshaping?
(3, 3)
34
quiz_scores = np.array([[85, 90, 92], [88, 82, 95], [75, 78, 80], ]) After reshaping quiz_scores to calculate the average score of each student, what is the shape of the reshaped array?
(3, 3)
35
What is the average score of Student 2?
88.33333333333333
36
When iterating over a 3D array, what does each iteration provide?
A 2D array
37
What does the hsplit() function do?
Splits an array horizontally
38
How can you search for multiple values, such as 2, 4, and 6, in a NumPy array?
np.where(arr == [2, 4, 6])
39
What will be the shape of an array after the operation arr.reshape(1, 2, 3, 2)?
(1, 2, 3, 2)
40
If you want to filter a 2D array to get elements greater than 4, Which of the following is correct?
arr_2d[arr_2d > 4]
41
Pag nakalimutan ko sagot, pahinge
Yes lang ang sagot, wala kang choice :p