ICT finals Flashcards

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?

A

arr[1, 1:4]

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?

A

(12,)

24
Q

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

A

(3, 2, 2)

25
Q

If you have a 2-D array and you iterate over it, what will you get?

A

Each row of the array

26
Q

What does the concatenate() function do in Numpy?

A

Joins a sequence of arrays along an existing axis

27
Q

How do you join two 1-D array along the second axis using Numpy?

A

np.stack((arr1, arr2), axis=1)

28
Q

walang questionnaire and no.28 pero may sagot

A

np.vstack()

29
Q

What is the result of splitting an array using np.array_split(arr, 3)?

A

A list containing three arrays

30
Q

How can you search for the value ‘4’ in a NumPy array?

A

np.where(arr == 4)

31
Q

What does the sort() function do in Numpy?

A

Orders the elements in an ascending od descending sequence

32
Q

How do you filter an array to only include elements greater than 42?

A

arr[arr > 42]

33
Q

quiz_scores = np.array([[85, 90, 92], [88, 82, 95], [75, 78, 80], ])

What is the shape of the quiz_scores array before reshaping?

A

(3, 3)

34
Q

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?

A

(3, 3)

35
Q

What is the average score of Student 2?

A

88.33333333333333

36
Q

When iterating over a 3D array, what does each iteration provide?

A

A 2D array

37
Q

What does the hsplit() function do?

A

Splits an array horizontally

38
Q

How can you search for multiple values, such as 2, 4, and 6, in a NumPy array?

A

np.where(arr == [2, 4, 6])

39
Q

What will be the shape of an array after the operation arr.reshape(1, 2, 3, 2)?

A

(1, 2, 3, 2)

40
Q

If you want to filter a 2D array to get elements greater than 4, Which of the following is correct?

A

arr_2d[arr_2d > 4]

41
Q

Pag nakalimutan ko sagot, pahinge

A

Yes lang ang sagot, wala kang choice :p