0% found this document useful (0 votes)
17 views11 pages

Extraai

Mcqs of artificial intelligence

Uploaded by

khannikhat2302
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views11 pages

Extraai

Mcqs of artificial intelligence

Uploaded by

khannikhat2302
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

1. What is a Random Forest?

Answer: B) An ensemble learning method that uses multiple decision trees

2. What is the K in K-Nearest Neighbors?

Answer: B) The number of nearest neighbors to consider for classification

3. Which of the following is a disadvantage of KNN?

Answer: C) It is computationally expensive for large datasets

4. What is a typical application of KNN?

Answer: B) Image recognition

5. What is the primary goal of regression analysis?

Answer: B) Predict continuous values

6. What is the cost function used in Linear Regression?

Answer: B) Mean Squared Error (MSE)

7. Which assumption is NOT made by Linear Regression?

Answer: D) Data follows a normal distribution

8. What type of output does Logistic Regression produce?

Answer: B) Categorical values

9. Which function is used in Logistic Regression to map predicted values to probabilities?

Answer: C) Sigmoid function

10. What is a common application of Logistic Regression?

Answer: B) Classifying emails as spam or not spam

1. What is the primary goal of clustering in machine learning?

Answer: C) Grouping similar data points together

2. Which of the following is NOT a type of clustering?

Answer: D) Decision tree clustering

3. In clustering, what is a cluster centroid?

Answer: B) The geometric center of a cluster

4. What is the K in K-Means clustering?

Answer: A) The number of clusters

5. What is the main objective of the K-Means algorithm?

Answer: A) To minimize the sum of squared distances between points and their respective cluster
centroids
6. Which of the following is an advantage of clustering?

Answer: C) Can discover hidden patterns in data without supervision

7. What is a disadvantage of K-Means clustering?

Answer: C) It is sensitive to the initial placement of centroids

8. Which of the following is a common application of K-Means clustering?

Answer: A) Image compression

9. Which of the following is a disadvantage of clustering?

Answer: B) The results can be highly sensitive to the choice of distance metric

10. In which scenario would you use clustering?

Answer: B) To group customers based on purchasing behavior

1. Which Python library is commonly used for implementing K-Means clustering?

Answer: B) scikit-learn

2. Which function in scikit-learn is used to perform K-Means clustering?

Answer: B) KMeans()

3. What parameter in the KMeans class specifies the number of clusters?

Answer: A) n_clusters

4. What method is used to fit a Decision Tree model in scikit-learn?

Answer: A) fit()

5. What type of output does Logistic Regression produce?

Answer: B) Categorical values

6. Which method in scikit-learn's LogisticRegression class is used to fit the model?

Answer: B) fit()

7. Which Python library is commonly used for implementing Support Vector Machines (SVM)?

Answer: B) scikit-learn

8. Which kernel can be used in scikit-learn's SVM implementation?

Answer: D) All of the above

9. Which function in scikit-learn is used to split data into training and testing sets?

Answer: A) train_test_split()

10. Which evaluation metric is suitable for classification problems?

Answer: C) Accuracy
Q.1 Which of the following is not a valid Python data type?

Answer: d) real

Q.2 What is the output of the following expression? 10 // 3

Answer: b) 3

Q.3 What will be the output of the following code?

x=5

y = 10

x += y

print(x)

Answer: c) 15

Q.4 Which of the following operators is used for string concatenation in Python?

Answer: c) +

Q.5 What will be the output of the following code?

x = "Hello"

y = 'World'

print(x + y)

Answer: b) HelloWorld

Q.6 What will be the result of the following expression? 5%2

Answer: b) 1

Q.7 What will be the output of the following code? print(2 ** 3)

Answer: c) 8

Q.8 Which of the following is the correct way to declare a variable and assign the value 10 to it in
Python?

Answer: b) x=10

Q.9 Which of the following methods can be used to convert a string to an integer in Python?

Answer: b) str()

Q.10 What will be the result of the following expression? 4 + 3 * 2

Answer: b) 10

Q.1 What does the // operator do in Python?

Answer: C) Floor Division

Q.2 Which arithmetic operator is used to find the remainder of the division? Answer: C) %
Q.3 What will be the output of the following code?

x=5

if x > 3:

print("Hello")

else:

print("Goodbye")

Answer: A) Hello

Q. 4 What is the purpose of the elif statement?

Answer: A) To handle multiple conditions

Q. 5 Which of the following is a valid if statement in Python?

Answer: C) if x == 5:

Q.6 Which of the following can be used to check multiple conditions in an if statement?

Answer: B) if-elif-else

Q.7 How do you check for inequality in an if statement?

Answer: C) x != y

Q.8 What will be the output of the following code?

x=0

if x:

print("True")

else:

print("False")

Answer: B) False

Q.9 How can you execute a block of code if a condition is false?

Answer: A) Using else statement

Q.10 How do you write a conditional expression in Python?

Answer: C) if x == 5

Q.1 Which of the following is true about nested if-else statements?

Answer: b) - They allow multiple conditions to be checked.

Q.2 What is the output of the following code?

x = 15

if x > 10:
if x > 20:

print("x is greater than 20")

else:

if x == 15:

print("x is 15")

Answer: b) x is 15

Q.3 Which of the following is the correct syntax for nested if-else in Python?

Answer: a) if condition1: if condition2: statement

Q.4 Which of the following is false about nested if-else?

Answer: d) It is equivalent to using multiple if statements independently.

Q.5 What will be the output of the following code?

x = -10

if x > 0:

if x % 2 == 0:

print("Positive even")

else:

print("Positive odd")

else:

if x % 2 == 0:

print("Negative even")

else:

print("Negative odd")

Answer: c) Negative even

Q.6 Which statement can be used to terminate a while loop prematurely? Answer: a) break

Q.7 What does the following code do?

x=5

while x > 0:

x -= 1

if x == 2:

break

print(x, end=' ') Answer: c) 4 3


Q.8 What will happen if the condition in a while loop never becomes False?

Answer: a) The loop will run infinitely

Q.9 Which of the following is correct syntax for a while loop?

Answer: d) while x == 5:

Q.10 Which of the following will execute a while loop 10 times?

Answer: c) x = 0 while x < 10: print(x) x += 1

Q.1 How can you iterate through a set s using a for loop?

A. for i in s: Answer: A

Q,2 What is the correct syntax to use a for loop to print each item in the list fruits?

A. for fruit in fruits: print(fruit) Answer: A

Q.3 Which function is used to create a sequence of numbers in a for loop?

B. range() Answer: B

Q.4 What is the correct syntax for a for loop in Python to iterate over a list named numbers?

B. for i in numbers:

Q. 5 What is the output of the following code?

for i in range(5, 8):

print(i)

B. 5 6 7 Answer: B

Q. 6 What is the output of the following code?

for i in range(2, 10, 2):

print(i)

B. 2 4 6 8 Answer: B

Q. 7 What is the output of the following code?

for i in range(1, 5):

if i == 3:

break

print(i)

B. 1 2 Answer: B

Q. 8 What is the output of the following code?

for i in range(3):

for j in range(2):
print(i, j)

B. (0, 0) (0, 1) (1, 0) (1, 1) (2, 0) (2, 1)

Q.9 How can you iterate through a set s using a for loop?

A. for i in s:

Q. 10 What is the output of the following code?

for i in range(2):

for j in range(3):

print(i + j)

Answer: D 0 1 2 0 1 2

1. Which library in Python is commonly used for data manipulation and analysis?

Answer: B) Pandas

2. Which Python library is primarily used for scientific computing and handling large
multidimensional arrays and matrices? Answer: C) NumPy

3. Which Python library would you use for creating static, interactive, and animated visualizations?

Answer: B) Matplotlib

4. Which library is used for machine learning and provides simple and efficient tools for data mining
and data analysis?

Answer: C) Scikit-learn

5. Which library provides high-level neural networks API, written in Python and capable of running
on top of TensorFlow, CNTK, or Theano?

Answer: A) Keras

6. Which Python library is designed for data visualization and is based on Matplotlib but provides a
higher-level interface for drawing attractive and informative statistical graphics?

Answer: B) Seaborn

7. Which library is used for numerical optimization, integration, interpolation, eigenvalue problems,
and other advanced mathematical operations?

Answer: B) SciPy

8. Which library provides an easy interface for creating static, interactive, and animated
visualizations in Python?

Answer: B) Plotly

9. Which library is used for machine learning in Python?

Answer: A) TensorFlow
10. Which library would you use to work with data visualization specifically designed for statistical
graphics in Python?

Answer: B) Seaborn

1. Which function in the Pandas library is used to display the first few rows of a DataFrame?

Answer: A) .head()

2. Which method in Pandas provides a summary of statistics pertaining to the DataFrame columns?

Answer: B) .describe()

3. Which method would you use to check for missing values in a DataFrame?

Answer: A) .isnull()

4. In Matplotlib, which function is used to create a basic line plot?

Answer: B) plt.plot()

5. Which Seaborn function is used to create a correlation heatmap?

Answer: B) sns.heatmap()

6. Which Pandas function is used to get the unique values of a column?

Answer: B) .unique()

7. Which Pandas method provides a quick overview of the DataFrame, including the number of non-
null entries and the data type of each column?

Answer: C) .info()

8. In Matplotlib, which function is used to create a bar chart?

Answer: C) plt.bar()

9. Which function in Pandas is used to read a CSV file?

Answer: A) pd.read_csv()

10. Which function in Matplotlib is used to create a histogram?

Answer: B) plt.hist()

Question 1: Which library is primarily used for data manipulation and analysis in Python?

Answer: D) Pandas

Question 2: Which Python library is most commonly used for numerical computing and handling
arrays?

Answer: B) NumPy

Question 3: Which library provides functions for scientific and technical computing such as
optimization, integration, and interpolation?

Answer: B) SciPy
Question 4: Which library is widely used for data visualization in Python, offering a wide range of
static, animated, and interactive plots?

Answer: C) Matplotlib

Question 5: Which function in Matplotlib is used to create a line plot?

Answer: C) plt.plot()

Question 6: Which of the following libraries can be used to create scatter plots in Python?

A) Matplotlib B) Seaborn C) Plotly D) All of the above

Question 7: Which Matplotlib function is used to create a bar plot?

Answer: B) plt.bar()

Question 8: Which parameter in plt.plot() can be used to specify the color of the line?

Answer: C) color

Question 9: Which Python library is used for working with large multidimensional arrays and
matrices, and includes a large collection of mathematical functions?

Answer: B) NumPy

Question 10: Which library is used for interactive visualizations and dashboards in Python?

Answer: C) Plotly

Q.1 What is the correct syntax to define a function in Python?

B. def myFunction():

Q.2 Which of the following is the correct way to call a function named calculate with no arguments?

C. calculate();

Q.3 What is the default return value of a function in Python if no return statement is used?

B. None

Q.4 What is the purpose of the return statement in a function?

C. To return a value to the caller

Q.5 What is the correct way to define a function that takes no parameters and returns no value?

A. def func(): pass

Q. 6 What will be the output of the following code?

def add(x, y=10):

return x + y

print(add(5)) A. 15

Q.7 Which of the following is true about function parameters in Python?

C. Parameters can be both positional and keyword


Q.8 Which of the following is true about the return statement in Python?

A. It can return multiple values C. It is optional D. Both A and C

Q. 9 What will be the output of the following code?

def func(a, b):

return a < b

print(func(5, 3))

A. False

Q.10 Which of the following is true about a function in Python?

C. A function can return multiple values

1. Which method is used to replace missing values in a Data Frame with the mean value of a
column? c. fillna()

2. What value is used to replace missing values when using the mode method in data pre-
processing?

c. The most frequently occurring value in the column

3. What value is used to replace missing values when using the median method in data pre-
processing?

b. The value in the middle after sorting all values ascending

4. Which pandas method is used to convert a column of dates into a standard date format?

b. to_datetime()

5. How can you remove rows with NULL values after converting a column to a standard date format?

a. df.dropna(subset=['Date'], inplace=True)

6. Which of the following is a common method for handling cells with wrong data formats?

a. Removing the entire row

7. What method can be used to remove duplicate rows in a DataFrame?

b. drop_duplicates()

8. Which encoding method is used to convert categorical labels into numeric form?

b. Label Encoding

9. Which method is used to replace missing values with the most frequently occurring value in a
column?

d. fillna(x.mode()[0])

10. Which of the following is NOT a common step in data preprocessing?

c. Increasing the number of rows

You might also like