Python Interview Questions – Part 3
━━━━━━━━━━━━━━━━━━━━━━
01. What is a Decorator in Python?
A decorator is a function that modifies or extends another function's behavior without changing its original source code.
Key Points
- Uses the
- Supports reusable functionality
- Commonly used for logging and access control
02. What is a Generator in Python?
A generator produces values one at a time instead of storing the entire sequence in memory.
Key Points
- Commonly uses the
- Generates values lazily
- Useful for processing large datasets
03. What is an Iterator in Python?
An iterator is an object that returns values one at a time using the
Key Points
- Supports the iterator protocol
- Works with
- Raises
04. What is the Use of the yield Keyword?
The
Key Points
- Produces values lazily
- Preserves local state between yields
- Helps reduce memory usage for large sequences
05. What is the Difference Between Shallow Copy and Deep Copy?
A shallow copy creates a new outer object but keeps references to nested objects. A deep copy recursively copies nested objects as well.
Key Points
- Shallow copy may share nested objects
- Deep copy duplicates nested structures
- Python provides
━━━━━━━━━━━━━━━━━━━━━━
UPDATEGADH | Technology Tutorials & Interview Questions
#Python #PythonInterviewQuestions #PythonProgramming #CodingInterview #PythonDevelopers #Programming #UPDATEGADH
━━━━━━━━━━━━━━━━━━━━━━
01. What is a Decorator in Python?
A decorator is a function that modifies or extends another function's behavior without changing its original source code.
Key Points
- Uses the
@decorator syntax- Supports reusable functionality
- Commonly used for logging and access control
02. What is a Generator in Python?
A generator produces values one at a time instead of storing the entire sequence in memory.
Key Points
- Commonly uses the
yield keyword- Generates values lazily
- Useful for processing large datasets
03. What is an Iterator in Python?
An iterator is an object that returns values one at a time using the
__next__() method until the sequence is exhausted.Key Points
- Supports the iterator protocol
- Works with
iter() and next()- Raises
StopIteration when exhausted04. What is the Use of the yield Keyword?
The
yield keyword returns a value from a generator while preserving its execution state. Execution resumes when the next value is requested.Key Points
- Produces values lazily
- Preserves local state between yields
- Helps reduce memory usage for large sequences
05. What is the Difference Between Shallow Copy and Deep Copy?
A shallow copy creates a new outer object but keeps references to nested objects. A deep copy recursively copies nested objects as well.
Key Points
- Shallow copy may share nested objects
- Deep copy duplicates nested structures
- Python provides
copy.copy() and copy.deepcopy()━━━━━━━━━━━━━━━━━━━━━━
UPDATEGADH | Technology Tutorials & Interview Questions
#Python #PythonInterviewQuestions #PythonProgramming #CodingInterview #PythonDevelopers #Programming #UPDATEGADH
Data Analysis Interview Questions – Part 2
━━━━━━━━━━━━━━━━━━━━━━
01. What is Mean in Data Analysis?
Mean is the arithmetic average of a dataset. It is calculated by dividing the sum of all values by the total number of values.
Key Points
- Represents the average value
- Sensitive to extreme values
- Used to summarize numerical data
02. What is Median?
Median is the middle value of a dataset after arranging the values in ascending or descending order.
Key Points
- Divides data into two halves
- Less affected by outliers than the mean
- For an even number of observations, it is the average of the two middle values
03. What is Mode?
Mode is the value that occurs most frequently in a dataset.
Key Points
- A dataset may have one mode, multiple modes, or no repeated-value mode
- Useful for categorical data
- Identifies the most frequent observation
04. What is Variance?
Variance measures how far data values are spread out from their mean by calculating the average squared deviation.
Key Points
- Higher variance indicates greater spread
- Expressed in squared units
- Can be calculated as population variance or sample variance
05. What is Standard Deviation?
Standard Deviation measures the spread of data values around the mean. It is the square root of variance.
Key Points
- Expressed in the same units as the data
- Lower values indicate less variability
- Useful for comparing data distributions
━━━━━━━━━━━━━━━━━━━━━━
UPDATEGADH | Technology Tutorials & Interview Questions
#DataAnalysis #DataAnalytics #Statistics #DataScience #InterviewQuestions #Python #UPDATEGADH
━━━━━━━━━━━━━━━━━━━━━━
01. What is Mean in Data Analysis?
Mean is the arithmetic average of a dataset. It is calculated by dividing the sum of all values by the total number of values.
Key Points
- Represents the average value
- Sensitive to extreme values
- Used to summarize numerical data
02. What is Median?
Median is the middle value of a dataset after arranging the values in ascending or descending order.
Key Points
- Divides data into two halves
- Less affected by outliers than the mean
- For an even number of observations, it is the average of the two middle values
03. What is Mode?
Mode is the value that occurs most frequently in a dataset.
Key Points
- A dataset may have one mode, multiple modes, or no repeated-value mode
- Useful for categorical data
- Identifies the most frequent observation
04. What is Variance?
Variance measures how far data values are spread out from their mean by calculating the average squared deviation.
Key Points
- Higher variance indicates greater spread
- Expressed in squared units
- Can be calculated as population variance or sample variance
05. What is Standard Deviation?
Standard Deviation measures the spread of data values around the mean. It is the square root of variance.
Key Points
- Expressed in the same units as the data
- Lower values indicate less variability
- Useful for comparing data distributions
━━━━━━━━━━━━━━━━━━━━━━
UPDATEGADH | Technology Tutorials & Interview Questions
#DataAnalysis #DataAnalytics #Statistics #DataScience #InterviewQuestions #Python #UPDATEGADH
Machine Learning Interview Questions – Part 2
━━━━━━━━━━━━━━━━━━━━━━
01. What is Linear Regression?
Linear Regression is a supervised machine learning algorithm used to predict a continuous numerical value by modeling the relationship between input variables and an output.
Key Points
- Used for numerical prediction
- Models linear relationships
- Example: predicting house prices
02. What is Logistic Regression?
Logistic Regression is a supervised learning algorithm commonly used for classification. It estimates the probability of an input belonging to a class.
Key Points
- Commonly used for binary classification
- Uses a logistic function in its standard form
- Example: spam or not-spam prediction
03. What is a Decision Tree?
A Decision Tree is a machine learning model that makes predictions using a sequence of feature-based decisions represented as branches.
Key Points
- Easy to interpret
- Supports classification and regression
- Can overfit without suitable constraints
04. What is Random Forest?
Random Forest is an ensemble learning algorithm that combines predictions from multiple decision trees to improve performance and reduce overfitting compared with a single unconstrained tree in many cases.
Key Points
- Uses multiple decision trees
- Supports classification and regression
- Combines predictions from individual trees
05. What is K-Nearest Neighbors (KNN)?
KNN is a supervised learning algorithm that predicts a class or numerical value using nearby training examples.
Key Points
- Uses a distance measure
- Classification often uses majority voting
- Performance depends on the choice of K and feature scaling
━━━━━━━━━━━━━━━━━━━━━━
UPDATEGADH | Technology Tutorials & Interview Questions
#MachineLearning #MLInterviewQuestions #ArtificialIntelligence #DataScience #Python #CodingInterview #UPDATEGADH
━━━━━━━━━━━━━━━━━━━━━━
01. What is Linear Regression?
Linear Regression is a supervised machine learning algorithm used to predict a continuous numerical value by modeling the relationship between input variables and an output.
Key Points
- Used for numerical prediction
- Models linear relationships
- Example: predicting house prices
02. What is Logistic Regression?
Logistic Regression is a supervised learning algorithm commonly used for classification. It estimates the probability of an input belonging to a class.
Key Points
- Commonly used for binary classification
- Uses a logistic function in its standard form
- Example: spam or not-spam prediction
03. What is a Decision Tree?
A Decision Tree is a machine learning model that makes predictions using a sequence of feature-based decisions represented as branches.
Key Points
- Easy to interpret
- Supports classification and regression
- Can overfit without suitable constraints
04. What is Random Forest?
Random Forest is an ensemble learning algorithm that combines predictions from multiple decision trees to improve performance and reduce overfitting compared with a single unconstrained tree in many cases.
Key Points
- Uses multiple decision trees
- Supports classification and regression
- Combines predictions from individual trees
05. What is K-Nearest Neighbors (KNN)?
KNN is a supervised learning algorithm that predicts a class or numerical value using nearby training examples.
Key Points
- Uses a distance measure
- Classification often uses majority voting
- Performance depends on the choice of K and feature scaling
━━━━━━━━━━━━━━━━━━━━━━
UPDATEGADH | Technology Tutorials & Interview Questions
#MachineLearning #MLInterviewQuestions #ArtificialIntelligence #DataScience #Python #CodingInterview #UPDATEGADH
Advanced AI Interview Questions
━━━━━━━━━━━━━━━━━━━━━━
01. What is the Attention Mechanism in AI?
Attention is a mechanism that allows a neural network to focus on the most relevant parts of the input while processing information.
Key Points
- Assigns importance to different input elements
- Used in Transformer architectures
- Helps LLMs understand relationships between tokens
02. What is Self-Attention?
Self-Attention calculates relationships between tokens within the same sequence using Query, Key, and Value representations.
Example:
In the sentence "The animal didn't cross the road because it was tired," self-attention can help the model relate "it" to "animal."
03. What is Retrieval-Augmented Generation (RAG)?
RAG combines information retrieval with text generation. It retrieves relevant documents and supplies them as context to an AI model before generating an answer.
Key Points
- Connects LLMs with external knowledge
- Can reduce unsupported answers when retrieval is relevant
- Used in document chatbots and knowledge assistants
04. What is the Difference Between RAG and Fine-Tuning?
RAG supplies external information during inference, while fine-tuning updates a model's parameters using training examples.
Key Points
- RAG is useful for frequently changing knowledge
- Fine-tuning can adapt behavior and output formats
- Both approaches can be combined
05. What is an AI Agent?
An AI Agent is a system that uses a model to interpret a goal, decide on actions, and interact with tools or external systems to complete tasks.
Example Workflow
User Request → Planning → Tool Call → Result Analysis → Final Response
━━━━━━━━━━━━━━━━━━━━━━
UPDATEGADH | Technology Tutorials & Interview Questions
#AdvancedAI #GenerativeAI #LLM #RAG #AIAgents #AIInterviewQuestions #Python #UPDATEGADH
━━━━━━━━━━━━━━━━━━━━━━
01. What is the Attention Mechanism in AI?
Attention is a mechanism that allows a neural network to focus on the most relevant parts of the input while processing information.
Key Points
- Assigns importance to different input elements
- Used in Transformer architectures
- Helps LLMs understand relationships between tokens
02. What is Self-Attention?
Self-Attention calculates relationships between tokens within the same sequence using Query, Key, and Value representations.
Example:
In the sentence "The animal didn't cross the road because it was tired," self-attention can help the model relate "it" to "animal."
03. What is Retrieval-Augmented Generation (RAG)?
RAG combines information retrieval with text generation. It retrieves relevant documents and supplies them as context to an AI model before generating an answer.
Key Points
- Connects LLMs with external knowledge
- Can reduce unsupported answers when retrieval is relevant
- Used in document chatbots and knowledge assistants
04. What is the Difference Between RAG and Fine-Tuning?
RAG supplies external information during inference, while fine-tuning updates a model's parameters using training examples.
Key Points
- RAG is useful for frequently changing knowledge
- Fine-tuning can adapt behavior and output formats
- Both approaches can be combined
05. What is an AI Agent?
An AI Agent is a system that uses a model to interpret a goal, decide on actions, and interact with tools or external systems to complete tasks.
Example Workflow
User Request → Planning → Tool Call → Result Analysis → Final Response
━━━━━━━━━━━━━━━━━━━━━━
UPDATEGADH | Technology Tutorials & Interview Questions
#AdvancedAI #GenerativeAI #LLM #RAG #AIAgents #AIInterviewQuestions #Python #UPDATEGADH