Home »
MCQs
AI with Python MCQs (Multiple-Choice Questions)
Artificial Intelligence (AI) enables computer systems to perform tasks that normally require human intelligence, such as learning from data, recognizing patterns, making predictions, understanding language, and making decisions. Python is widely used for AI development because of its extensive ecosystem of libraries and frameworks for machine learning, deep learning, data analysis, and natural language processing.
AI with Python MCQs
These AI with Python MCQs cover important concepts such as artificial intelligence, machine learning, supervised and unsupervised learning, classification, regression, clustering, neural networks, deep learning, model training, evaluation, scikit-learn, PyTorch, and AI applications.
List of AI with Python MCQs
The following AI with Python MCQs are designed to test your understanding of artificial intelligence concepts and their implementation using Python.
1. What does AI stand for?
- Automated Information
- Artificial Intelligence
- Advanced Integration
- Applied Internet
Answer: B) Artificial Intelligence
Explanation:
AI stands for Artificial Intelligence, a field focused on developing systems capable of performing tasks associated with human intelligence.
2. Which programming language is widely used for Artificial Intelligence?
- Python
- HTML
- CSS
- XML
Answer: A) Python
Explanation:
Python is widely used for AI and machine learning because of its extensive ecosystem of libraries and frameworks.
3. Which Python library provides tools for machine learning?
- scikit-learn
- tkinter
- socket
- pathlib
Answer: A) scikit-learn
Explanation:
scikit-learn provides tools for predictive data analysis, including classification, regression, clustering, preprocessing, dimensionality reduction, and model selection.
4. Which Python framework is commonly used for deep learning?
- PyTorch
- Flask
- Beautiful Soup
- Requests
Answer: A) PyTorch
Explanation:
PyTorch is a deep learning framework that provides tensors, automatic differentiation, neural-network modules, optimization tools, and other features used to build machine learning models.
5. Which type of machine learning uses labeled training data?
- Supervised learning
- Unsupervised learning
- Random learning
- Unstructured learning
Answer: A) Supervised learning
Explanation:
Supervised learning trains a model using input data together with known target or output values.
6. Which type of machine learning works with data without predefined target labels?
- Supervised learning
- Unsupervised learning
- Rule-based learning
- Deterministic learning
Answer: B) Unsupervised learning
Explanation:
Unsupervised learning discovers patterns or structures in data without using predefined target labels.
7. Which machine learning task predicts a category or class?
- Regression
- Classification
- Clustering
- Dimensionality reduction
Answer: B) Classification
Explanation:
Classification is used when the target is a category, such as spam or not spam.
8. Which machine learning task predicts a continuous numerical value?
- Classification
- Regression
- Clustering
- Association
Answer: B) Regression
Explanation:
Regression models predict continuous-valued targets, such as prices, temperatures, or numerical measurements.
9. Which machine learning technique groups similar data points together?
- Regression
- Classification
- Clustering
- Prediction
Answer: C) Clustering
Explanation:
Clustering is an unsupervised learning technique used to automatically group similar data points.
10. Which algorithm is commonly used for clustering?
- K-Means
- Linear Regression
- Logistic Regression
- Naive Bayes
Answer: A) K-Means
Explanation:
K-Means is a popular clustering algorithm that partitions data into a specified number of clusters.
11. Which algorithm is commonly used for binary classification?
- Logistic Regression
- K-Means
- PCA
- Linear Regression only
Answer: A) Logistic Regression
Explanation:
Logistic Regression is commonly used for classification problems, including binary classification.
12. Which algorithm is based on decision trees and combines multiple trees?
- Random Forest
- K-Means
- Linear Regression
- PCA
Answer: A) Random Forest
Explanation:
Random Forest is an ensemble learning method that combines predictions from multiple decision trees.
13. Which algorithm predicts values using a linear relationship between variables?
- Linear Regression
- K-Means
- Decision Tree Classifier
- DBSCAN
Answer: A) Linear Regression
Explanation:
Linear Regression models a linear relationship between input features and a continuous target.
14. Which algorithm can classify data by finding a separating hyperplane?
- Support Vector Machine
- K-Means
- PCA
- Apriori
Answer: A) Support Vector Machine
Explanation:
Support Vector Machines can be used for classification by finding decision boundaries that separate classes.
15. Which algorithm is based on the idea of finding the nearest training examples?
- K-Nearest Neighbors
- Random Forest
- Naive Bayes
- PCA
Answer: A) K-Nearest Neighbors
Explanation:
K-Nearest Neighbors predicts the class or value of an observation based on nearby training examples.
16. Which algorithm is based on Bayes' theorem and commonly used for classification?
- Naive Bayes
- K-Means
- Random Forest
- Linear Regression
Answer: A) Naive Bayes
Explanation:
Naive Bayes classifiers use Bayes' theorem together with a conditional independence assumption between features.
17. What is a feature in a machine learning dataset?
- An input variable used by a model
- The final prediction only
- The model itself
- A programming language
Answer: A) An input variable used by a model
Explanation:
A feature is an input variable or measurable characteristic used by a machine learning model to make predictions.
18. What is a target in supervised machine learning?
- The input feature
- The value the model is trained to predict
- The Python interpreter
- The dataset filename
Answer: B) The value the model is trained to predict
Explanation:
The target, also called the label or output, is the value that a supervised learning model learns to predict.
19. Which function is commonly used to split data into training and testing sets in scikit-learn?
- train_test_split()
- split_data()
- divide_dataset()
- dataset_splitter()
Answer: A) train_test_split()
Explanation:
train_test_split() from sklearn.model_selection splits arrays or datasets into random training and testing subsets.
20. Why is a dataset commonly divided into training and testing sets?
- To evaluate how the trained model performs on unseen data
- To increase the number of features
- To remove Python syntax
- To convert classification into clustering
Answer: A) To evaluate how the trained model performs on unseen data
Explanation:
A test set provides data that was not used for training and can therefore be used to evaluate model performance on unseen examples.
21. Which method is generally used to train a scikit-learn estimator?
- fit()
- train()
- learn()
- build()
Answer: A) fit()
Explanation:
Scikit-learn estimators generally use the fit() method to learn model parameters from training data.
22. Which method is commonly used to generate predictions from a trained scikit-learn model?
- predict()
- forecast()
- output()
- classify_only()
Answer: A) predict()
Explanation:
Many scikit-learn estimators provide the predict() method for generating predictions from new input data.
23. What is overfitting in machine learning?
- When a model learns the training data too closely and performs poorly on new data
- When a model has no training data
- When all features are removed
- When a dataset contains only numbers
Answer: A) When a model learns the training data too closely and performs poorly on new data
Explanation:
Overfitting occurs when a model captures patterns specific to the training data, including noise, and does not generalize well to unseen data.
24. What is underfitting?
- When a model is too simple to capture important patterns in the data
- When a model memorizes all training examples
- When a dataset has too many rows
- When a model has no features
Answer: A) When a model is too simple to capture important patterns in the data
Explanation:
Underfitting occurs when a model is not sufficiently capable of representing the underlying patterns in the data.
25. Which technique is commonly used to evaluate a model using multiple train-validation splits?
- Cross-validation
- Data deletion
- Feature removal
- Random formatting
Answer: A) Cross-validation
Explanation:
Cross-validation repeatedly splits the data into training and validation portions to obtain a more robust estimate of model performance.
26. Which metric is commonly used to evaluate classification accuracy?
- accuracy_score
- mean_squared_error
- r2_score_only
- mean_absolute_error_only
Answer: A) accuracy_score
Explanation:
accuracy_score calculates the fraction or count of correctly classified samples, depending on its configuration.
27. Which metric is commonly used for regression problems?
- Mean Squared Error
- Accuracy
- Precision only
- Recall only
Answer: A) Mean Squared Error
Explanation:
Mean Squared Error (MSE) measures the average squared difference between predicted and actual target values and is commonly used for regression.
28. What does a confusion matrix summarize?
- Classification results by comparing predicted and actual classes
- Only regression errors
- Only training time
- Only feature names
Answer: A) Classification results by comparing predicted and actual classes
Explanation:
A confusion matrix summarizes classification predictions by comparing predicted classes with the actual classes.
29. What does precision measure in classification?
- The proportion of predicted positive cases that are actually positive
- The proportion of all samples that are negative
- The number of training iterations
- The number of input features
Answer: A) The proportion of predicted positive cases that are actually positive
Explanation:
Precision measures the proportion of predicted positive instances that are actually positive.
30. What does recall measure in classification?
- The proportion of actual positive cases that are correctly identified
- The number of features used by the model
- The number of classes only
- The training time
Answer: A) The proportion of actual positive cases that are correctly identified
Explanation:
Recall measures the proportion of actual positive instances that are correctly identified by the classifier.
31. What is a neural network?
- A model inspired by networks of interconnected processing units
- A database system
- A Python package manager
- A web server
Answer: A) A model inspired by networks of interconnected processing units
Explanation:
Artificial neural networks consist of interconnected computational units, commonly organized into layers, that learn patterns from data.
32. Which component of a neural network applies a transformation to its input?
- Activation function
- File handler
- Database cursor
- HTTP request
Answer: A) Activation function
Explanation:
Activation functions introduce nonlinear transformations into neural networks, allowing them to learn complex patterns.
33. Which activation function is commonly used in hidden layers of neural networks?
- ReLU
- CSV
- HTTP
- JSON
Answer: A) ReLU
Explanation:
ReLU, or Rectified Linear Unit, is a commonly used activation function in neural networks.
34. What is deep learning?
- A branch of machine learning involving neural networks with multiple layers
- A method for sorting Python lists
- A database query technique
- A file compression method
Answer: A) A branch of machine learning involving neural networks with multiple layers
Explanation:
Deep learning uses neural networks with multiple layers to learn increasingly complex representations of data.
35. What is a tensor in PyTorch?
- A multi-dimensional array-like data structure
- A database table
- A Python string
- A web request
Answer: A) A multi-dimensional array-like data structure
Explanation:
PyTorch tensors are multi-dimensional data structures used to store and process numerical data for machine learning and deep learning.
36. Which Python package provides the Tensor class used by PyTorch?
- torch
- pytorch.tensorlib
- torchdataonly
- deep.tensor
Answer: A) torch
Explanation:
The main PyTorch package is imported as torch and provides tensor operations and many other machine learning capabilities.
37. Which PyTorch feature automatically computes gradients?
- Autograd
- AutoData
- GradientLoader
- TensorFlow
Answer: A) Autograd
Explanation:
PyTorch's automatic differentiation system, commonly known as Autograd, computes gradients needed for optimization.
38. Which PyTorch method is commonly used to calculate gradients during backpropagation?
- backward()
- gradient()
- calculate_grad()
- propagate()
Answer: A) backward()
Explanation:
The backward() method is commonly used to initiate automatic differentiation and compute gradients.
39. What is the purpose of an optimizer in machine learning?
- To update model parameters based on gradients
- To display images
- To load HTML pages
- To rename datasets
Answer: A) To update model parameters based on gradients
Explanation:
Optimizers update model parameters using gradients calculated during training to minimize the model's loss.
40. Which PyTorch package provides neural network modules?
- torch.nn
- torch.network
- torch.neural
- torch.layers
Answer: A) torch.nn
Explanation:
The torch.nn package provides building blocks for constructing neural networks.
41. Which PyTorch class is commonly used as the base class for custom neural network models?
- torch.nn.Module
- torch.nn.Network
- torch.Model
- torch.NeuralModel
Answer: A) torch.nn.Module
Explanation:
Custom PyTorch neural network models generally inherit from torch.nn.Module.
42. What is the purpose of a loss function in machine learning?
- To measure the difference between predictions and target values
- To load the training dataset
- To increase the number of classes
- To create Python packages
Answer: A) To measure the difference between predictions and target values
Explanation:
A loss function quantifies how different the model's predictions are from the desired target values and provides a signal used during training.
43. What is an epoch in model training?
- One complete pass through the training dataset
- One feature in the dataset
- One class label
- One prediction only
Answer: A) One complete pass through the training dataset
Explanation:
An epoch generally refers to one complete pass through the training dataset during model training.
44. What is a batch in machine learning?
- A subset of training examples processed together
- The complete source code
- A single model parameter
- A classification label
Answer: A) A subset of training examples processed together
Explanation:
A batch is a group of training examples processed together during an optimization step.
45. What is reinforcement learning based on?
- Learning through interactions using rewards or penalties
- Only labeled static datasets
- Only clustering data
- Only image resizing
Answer: A) Learning through interactions using rewards or penalties
Explanation:
Reinforcement learning involves an agent interacting with an environment and learning behavior based on rewards and penalties.
46. Which AI field focuses on enabling computers to process and understand human language?
- Natural Language Processing
- Computer Graphics
- Database Management
- Operating Systems
Answer: A) Natural Language Processing
Explanation:
Natural Language Processing (NLP) focuses on processing, analyzing, and generating human language using computational methods.
47. Which AI field focuses on interpreting images and visual information?
- Computer Vision
- Natural Language Processing
- Data Warehousing
- Network Programming
Answer: A) Computer Vision
Explanation:
Computer Vision is an AI field concerned with analyzing and understanding visual information such as images and video.
48. What is dimensionality reduction used for?
- Reducing the number of features or dimensions in data
- Increasing the number of duplicate records
- Adding random labels
- Converting Python into another language
Answer: A) Reducing the number of features or dimensions in data
Explanation:
Dimensionality reduction transforms data into a lower-dimensional representation while attempting to preserve useful information.
49. Which algorithm is commonly used for dimensionality reduction?
- Principal Component Analysis
- Random Forest
- Logistic Regression
- K-Nearest Neighbors
Answer: A) Principal Component Analysis
Explanation:
Principal Component Analysis (PCA) is a commonly used dimensionality-reduction technique that transforms data into a set of principal components.
50. Which statement best describes AI with Python?
- Python can be used for AI through libraries and frameworks for machine learning, deep learning, NLP, computer vision, and data processing
- Python can only be used for simple mathematical calculations in AI
- Python is used only for creating AI databases
- Python does not support machine learning
Answer: A) Python can be used for AI through libraries and frameworks for machine learning, deep learning, NLP, computer vision, and data processing
Explanation:
Python has a broad AI and machine learning ecosystem. Python.org lists tools such as PyTorch, TensorFlow, scikit-learn, Transformers, and other AI-related technologies, while scikit-learn and PyTorch provide dedicated APIs for machine learning and deep learning workflows.
Advertisement
Advertisement