Essential Programming and Data Science Q&A
Python Fundamentals
Q: What is the difference between if, elif, and else?
ifchecks an initial condition.elifchecks another condition if the previous one is false.elseruns if none of the preceding conditions are true.
Q: When do we use a for loop instead of while?
- We use
forwhen we know the number of iterations. whileis used when the condition controls the loop execution.
Q: What is an infinite loop?
A loop that never stops because its condition is always true.
Q: What is a function?
A reusable block of code that performs a specific task.
Q: What is the difference between parameter and argument?
- A parameter is defined in the function signature.
- An argument is the value passed when calling the function.
Q: What is a return value?
The output that a function sends back to the caller.
Q: What are main data types in Python?
Integer, float, string, Boolean, list, tuple, dictionary.
Q: Difference between list and tuple?
- List is mutable (can change).
- Tuple is immutable (cannot change).
Object-Oriented Programming (OOP)
Q: What is a class?
A blueprint for creating objects.
Q: What is an object?
An instance of a class.
Q: What is inheritance?
When one class inherits properties and methods from another class.
Pandas Data Structures
Q: What is a DataFrame?
A 2D table structure with rows and columns.
Q: How do you load a CSV file in pandas?
Using pd.read_csv().
Q: How do you filter rows?
Using conditions like df[df["age"] > 30].
Arrays and Lists
Q: What is an array?
A collection of elements stored in contiguous memory.
Q: Time complexity to access an element?
O(1), constant time.
Q: How do you add an element?
Using append().
Q: What is slicing?
Extracting part of a list using indexes.
Dictionaries
Q: What is a dictionary?
A data structure that stores key-value pairs.
Q: How do you access a value?
Using the key, like dict[key].
Linux Shell Commands
Q: What is the Linux shell?
A command-line interface to interact with the system.
Q: What does cd do?
Changes directory.
Q: What does ls do?
Lists files in a directory.
Q: What does cp do?
Copies files.
Q: What does cat do?
Displays file content.
SQL Database Concepts
Q: What is a relational database?
A database that stores data in tables with relationships.
Q: What is a primary key?
A unique identifier for each row.
Q: What is a foreign key?
A field that links to the primary key of another table.
Q: Select all columns?
SELECT * FROM table;
Q: Filter rows?
Using WHERE.
Q: What is GROUP BY?
Groups rows with the same values for aggregation.
Q: Difference between INNER JOIN and LEFT JOIN?
- INNER JOIN returns matching rows only.
- LEFT JOIN returns all rows from the left table and matches from the right.
Probability Basics
Q: What is a sample space?
The set of all possible outcomes.
Q: What is conditional probability?
Probability of an event given another event occurred.
Q: What does independence mean?
One event does not affect the probability of another.
Q: State Bayes’ theorem.
It updates probability based on new evidence.
Random Variables
Q: What is a random variable?
A variable that takes numerical values based on chance.
Q: Difference between discrete and continuous?
- Discrete has countable values.
- Continuous has infinite values.
Q: What is expected value?
The average value of a random variable.
Q: What is variance?
Measure of spread around the mean.
Central Limit Theorem (CLT)
Q: What is CLT?
The sample mean becomes normally distributed as sample size increases.
Q: Mean?
Average value.
Q: Standard deviation?
Square root of variance.
Statistical Inference
Q: What is a confidence interval?
A range that likely contains the true parameter.
Q: What is null hypothesis?
The default assumption of no effect.
Q: What is p-value?
Probability of observing data if the null hypothesis is true.
Linear Regression
Q: What is linear regression?
A method to model the relationship between variables.
