0% found this document useful (0 votes)
8 views

Set 2

Uploaded by

tmkumar1018
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Set 2

Uploaded by

tmkumar1018
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Set 2

Python Intermediate MCQs

1. What is the result of this code?

a = [1, 2, 3]

b = a.copy()

b.append(4)

print(a)

a) [1, 2, 3]
b) [1, 2, 3, 4]
c) Error
d) None

2. Which method is used to remove the last item from a list?


a) remove()
b) del()
c) pop()
d) clear()

3. What will be the output of this code?

a = {1, 2, 3}

a.add(4)

print(a)

a) {1, 2, 3}
b) {1, 2, 3, 4}
c) Error
d) None

4. Which of the following data types is hashable?


a) List
b) Set
c) Tuple
d) Dictionary

5. What will be the output of this code?

def test(a, *args):

print(len(args))
test(1, 2, 3, 4)

a) 3
b) 4
c) 1
d) Error

6. What does the is operator compare?


a) Values of two objects
b) Memory addresses of two objects
c) Data types of two objects
d) None of the above

7. What is the output of this code?

a = "Python"

print(a[::-1])

a) Python
b) nohtyP
c) Error
d) None

8. What is the purpose of * in function arguments?


a) Unpack dictionaries into keyword arguments
b) Combine multiple positional arguments into a tuple
c) Modify function return values
d) None of the above

9. What will be the output of this code?

a = [0, 1, 2, 3, 4]

print(a[1:-1])

a) [1, 2, 3]
b) [0, 1, 2, 3]
c) [0, 1, 2, 3, 4]
d) Error

10. Which method is used to return the length of a dictionary?


a) size()
b) count()
c) len()
d) length()

11. What will the following code return?

print([1, 2, 3] + [4, 5])

a) [1, 2, 3, 4, 5]
b) 12345
c) Error
d) None

12. What is the output of this code?

print(set([1, 1, 2, 2, 3, 3]))

a) [1, 2, 3]
b) (1, 2, 3)
c) {1, 2, 3}
d) None

13. What does the any() function return?


a) True if any element of the iterable is truthy.
b) The number of truthy elements.
c) True if all elements are truthy.
d) None of the above.

14. What is the difference between is and ==?


a) is compares memory locations, == compares values.
b) is compares values, == compares data types.
c) Both are identical.
d) None of the above.

15. What will the following code output?

def test(a, b=10):

return a + b

print(test(5))

a) 5
b) 15
c) 10
d) Error

Machine Learning MCQs

1. What is the goal of supervised learning?


a) Find hidden patterns in the data.
b) Predict outcomes based on labeled data.
c) Cluster data into groups.
d) None of the above.

2. Which of the following is a type of unsupervised learning?


a) Regression
b) Classification
c) Clustering
d) All of the above

3. Which algorithm is used to minimize the loss function in linear regression?


a) Gradient Descent
b) Backpropagation
c) Cross Entropy
d) K-Means

4. Which library is commonly used for data manipulation in Python?


a) NumPy
b) Pandas
c) Matplotlib
d) TensorFlow

5. What does a confusion matrix show?


a) Data visualization
b) Clustering groups
c) True/False predictions and errors
d) None of the above

6. What is the purpose of feature scaling?


a) Reduce overfitting
b) Normalize data for better algorithm performance
c) Increase accuracy
d) None of the above
7. Which of these is a dimensionality reduction technique?
a) K-Means
b) PCA
c) CNN
d) Random Forest

8. Which activation function is most suitable for multi-class classification?


a) Sigmoid
b) Softmax
c) ReLU
d) Linear

9. What is the purpose of a learning curve?


a) Analyze training vs. testing performance.
b) Determine feature importance.
c) Visualize data distribution.
d) Cluster data.

10. Which of the following is an ensemble method?


a) Logistic Regression
b) Random Forest
c) PCA
d) KNN

11. What is dropout in neural networks?


a) A form of regularization to prevent overfitting.
b) A method to increase learning rate.
c) A data preprocessing technique.
d) None of the above.

12. What does "epochs" mean in training a neural network?


a) Number of training data points used.
b) Number of complete passes over the training dataset.
c) Number of layers in the network.
d) None of the above.

13. What is the purpose of cross-validation?


a) To split data into training and test sets.
b) To evaluate model performance on unseen data.
c) To reduce dataset size.
d) None of the above.
14. Which algorithm is typically used for anomaly detection?

a) PCA

b) Isolation Forest

c) CNN

d) SVM

15. What is the objective of a cost function?


a) Minimize the error in predictions.
b) Maximize model accuracy.
c) Select the best features.
d) None of the above.

You might also like