Numpy array arr is defined as follows :
arr = np.array([1,2,3,4,5,6,7])
Which one of the following returns the even numbers in the array ?
Senz AIoT Savants - ML & C++
Quiz
•
Computers
•
Professional Development
•
Hard
Kavinda Perera
Used 1+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
Numpy array arr is defined as follows :
arr = np.array([1,2,3,4,5,6,7])
Which one of the following returns the even numbers in the array ?
print(arr(0: step = 2))
print(arr(1: step = 2))
print(arr[1::2])
print(arr[::2])
Answer explanation
arr[::2] means to select every 2nd element from the array starting from the first element, i.e., [1, 3, 5, 7]. This works because the even numbers in the array are at positions that are multiples of 2, starting from the first element at position 0.
The other options are:
print(arr(0: step = 2)): This is not valid Python syntax. It should be arr[::2].
print(arr(1: step = 2)): This is not valid Python syntax. It should be arr[1::2].
print(arr[1::2]): This returns [2, 4, 6], which are the odd numbers in the array. This is because we start selecting elements from position 1, which is the second element, and then select every 2nd element from there.
2.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
A Python dataframe is defined according to the code shown in the picture. What is the data type (dtype) of column “Age” ?
Int64
String
object
Above snippet will give an error
Answer explanation
In the given DataFrame, the column "Age" has values of mixed data types - integers and a string ("hello"). When a column in a Pandas DataFrame has mixed data types, Pandas assigns the data type that can accommodate all the data in the column, which is usually the object data type.
In this case, since the "Age" column has a string value, Pandas assigns the data type of the column to object. If we try to perform numerical operations on this column, it will result in a TypeError due to the presence of the string value.
3.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
Which of the following is a method for reducing the dimensionality of a dataset?
Normalization
Standardization
One-hot encoding
Principal component analysis (PCA)
Answer explanation
PCA is a technique for reducing the dimensionality of a dataset by projecting it onto a lower-dimensional space while preserving as much of the variance in the data as possible. Normalization, standardization, and one-hot encoding are all preprocessing techniques that are not specifically designed for dimensionality reduction.
4.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
Which of the following evaluation metrics is commonly used for measuring the performance of object detection algorithms?
Precision-Recall curve
F1-score
Mean Average Precision (mAP)
Receiver Operating Characteristic (ROC) curve
Answer explanation
While Precision-Recall curve, F1-score, and Receiver Operating Characteristic (ROC) curve are also commonly used metrics for evaluating the performance of machine learning algorithms, they are more suitable for binary classification problems. Object detection is a multi-class classification problem, and mAP is specifically designed to evaluate the accuracy of object detection algorithms.
5.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
What is the output of the following code snippet?
[1, 2, 3]
[1, 4, 3]
[1, 2, 4]
[4, 2, 3]
Answer explanation
In this code, we create a list x with the values [1, 2, 3]. We then make a copy of this list and assign it to y. Next, we change the second element of x to 4. Finally, we print the value of y. Since y is a copy of x, changing x does not affect y, so the output will be [1, 2, 3].
6.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
Which of the following is NOT a common preprocessing step in machine learning?
Normalization
Standardization
One-hot encoding
Feature selection
Answer explanation
While feature selection is a common technique for reducing the number of features in a dataset, it is not considered a preprocessing step in the same way that normalization, standardization, and one-hot encoding are.
7.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
What is the output of the following C++ code snippet?
5 7
7 5
7 7
Compilation Error
Answer explanation
This code initializes two integer variables x and y with the values 5 and 7 respectively. It then declares two integer pointers p1 and p2 and sets them to point to the memory addresses of x and y respectively.
The next line is where things get interesting: p1 = p2;. This line is assigning the value pointed to by p2 (which is y) to the value pointed to by p1 (which is x). So after this line executes, x will have the value 7, and y will still have the value 7.
Finally, the code prints out the values of x and y on the same line separated by a space using cout << x << " " << y << endl;. The output of this code will be: 7 7
In summary, the code swaps the values of x and y by using pointers, and then outputs the new values of both variables.
10 questions
Python Collections
Quiz
•
Professional Development
10 questions
Basic Python
Quiz
•
Professional Development
5 questions
Python - Numpy Quiz 1
Quiz
•
University - Professi...
10 questions
Python Basics
Quiz
•
Professional Development
15 questions
Javascript basics
Quiz
•
Professional Development
5 questions
Python - Numpy Quiz 3
Quiz
•
University - Professi...
13 questions
Strings and Arrays
Quiz
•
Professional Development
10 questions
python quiz
Quiz
•
6th Grade - Professio...
15 questions
Character Analysis
Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing
Quiz
•
9th - 12th Grade
10 questions
American Flag
Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension
Quiz
•
5th Grade
30 questions
Linear Inequalities
Quiz
•
9th - 12th Grade
20 questions
Types of Credit
Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25
Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers
Quiz
•
6th - 8th Grade