0% found this document useful (0 votes)
18 views16 pages

Python DataScience QA Bank

The document is a comprehensive question and answer bank for Python and Data Science, organized into six units covering topics from Python basics to data visualization. Each unit contains 40 questions designed for exam revision, addressing key concepts, definitions, and applications in Python programming and data science. It serves as a study guide for learners seeking to enhance their knowledge and skills in these areas.

Uploaded by

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

Python DataScience QA Bank

The document is a comprehensive question and answer bank for Python and Data Science, organized into six units covering topics from Python basics to data visualization. Each unit contains 40 questions designed for exam revision, addressing key concepts, definitions, and applications in Python programming and data science. It serves as a study guide for learners seeking to enhance their knowledge and skills in these areas.

Uploaded by

bhuvi143shizu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python and Data Science

Complete Question and Answer Bank

6 Units | 40 Questions Each | 240 Total Q&A

Unit 1: Python Basics | Unit 2: Functions and OOP


Unit 3: Data Science Foundations | Unit 4: Descriptive Analytics
Unit 5: NumPy and Pandas | Unit 6: Data Visualization

Prepared for Exam Revision


UNIT 1 - BASICS OF PYTHON
Introduction | Language Fundamentals | Data Types | Variables | Operators | Control Flow | Data Structures

Q1. What is Python?


A: Python is a high-level, interpreted, interactive, and object-oriented programming language.
Q2. Who created Python and in which year?
A: Guido van Rossum created Python and it was first released in 1991.
Q3. What does interpreted language mean?
A: Code is executed line by line by an interpreter without prior compilation into machine code.
Q4. Is Python case-sensitive?
A: Yes. Python is case-sensitive, so Name and name are treated as different identifiers.
Q5. What is the file extension for Python source files?
A: .py
Q6. What is indentation in Python?
A: The use of spaces or tabs to define blocks of code instead of curly braces.
Q7. How many spaces are recommended per indentation level according to PEP 8?
A: 4 spaces per indentation level.
Q8. What are keywords in Python?
A: Reserved words with special meaning that cannot be used as identifiers, e.g., if, for, while, return,
class.
Q9. How many keywords exist in Python 3?
A: 35 keywords.
Q10. What is a Python identifier?
A: A name used to identify a variable, function, class, module, or other object in Python.
Q11. What is the data type of the value 10?
A: int (integer).
Q12. What is the data type of 3.14?
A: float (floating-point number).
Q13. What is the data type of 3+4j?
A: complex (complex number with real and imaginary parts).
Q14. What are the two Boolean values in Python?
A: True and False.
Q15. Which data type stores a sequence of characters?
A: str (string).
Q16. What is a list in Python?
A: An ordered, mutable collection of items enclosed in square brackets, e.g., [1, 2, 3].
Q17. What is a tuple in Python?
A: An ordered, immutable collection of items enclosed in parentheses, e.g., (1, 2, 3).
Q18. What is a set in Python?
A: An unordered collection of unique elements enclosed in curly braces, e.g., {1, 2, 3}.
Q19. What is a dictionary in Python?
A: A collection of key-value pairs enclosed in curly braces, e.g., {'name': 'Alice', 'age': 20}.
Q20. What is dynamic typing in Python?
A: The variable type is determined automatically at runtime, not at the time of declaration.
Q21. Which built-in function returns the data type of a variable?
A: type() - e.g., type(10) returns int.
Q22. What does the int() function do?
A: Converts a value to an integer data type, e.g., int('5') returns 5.
Q23. What does the ** operator do in Python?
A: Exponentiation - raises a number to a power. Example: 2**3 = 8.
Q24. What does the % operator do in Python?
A: Modulus - returns the remainder after division. Example: 10 % 3 = 1.
Q25. What does the // operator do in Python?
A: Floor division - divides and returns the quotient without the decimal part. Example: 7//2 = 3.
Q26. Which relational operator checks equality between two values?
A: == (double equals sign).
Q27. What are the three logical operators in Python?
A: and, or, not.
Q28. What is the result of not True in Python?
A: False.
Q29. What is an assignment operator? Give an example.
A: Used to assign or update values in variables. Example: x += 5 adds 5 to x.
Q30. What does the bitwise AND operator & do in Python?
A: Performs AND operation on each corresponding bit of two integers.
Q31. What is an if statement used for?
A: To execute a block of code only when a specified condition evaluates to True.
Q32. What is the purpose of an if-else statement?
A: Executes one block if the condition is True, and an alternative block if the condition is False.
Q33. What is a nested if statement?
A: An if or if-else statement placed inside another if or else block.
Q34. What is a for loop used for?
A: To iterate over a sequence such as a list, tuple, string, or range object.
Q35. What does range(1, 5) produce?
A: Numbers 1, 2, 3, 4. The stop value 5 is excluded.
Q36. What is a while loop?
A: A loop that keeps executing as long as its given condition remains True.
Q37. What does the break statement do?
A: Immediately exits the nearest enclosing loop when encountered.
Q38. What does the continue statement do?
A: Skips the remaining statements in the current iteration and jumps to the next iteration.
Q39. What does the pass statement do?
A: A null statement that acts as a placeholder in loops, functions, or classes where no action is needed.
Q40. What is the key difference between a list and a tuple?
A: A list is mutable (elements can be added, removed, or changed); a tuple is immutable (elements
cannot be changed after creation).
UNIT 2 - FUNCTIONS, FILES AND OOP
Functions | Object-Oriented Concepts | Strings | File Handling | Exception Handling | Libraries

Q1. What keyword is used to define a function in Python?


A: def
Q2. What is a function in Python?
A: A reusable, named block of code that performs a specific task when called.
Q3. What does a return statement do in a function?
A: It sends a value back from the function to the place where it was called.
Q4. What are positional arguments?
A: Arguments passed to a function in the exact order the parameters are defined.
Q5. What are keyword arguments?
A: Arguments passed using the parameter name explicitly, e.g., func(name='John').
Q6. What are default arguments?
A: Parameters that have a preset default value used when no argument is provided during the call.
Q7. What is a recursive function?
A: A function that calls itself repeatedly until a base condition is satisfied.
Q8. What is a base condition in recursion?
A: The condition that stops further recursive calls, preventing an infinite loop.
Q9. What does a function return if it has no return statement?
A: None.
Q10. What is a class in Python?
A: A blueprint or template for creating objects that encapsulates data (attributes) and behaviour
(methods).
Q11. What is an object in Python?
A: An instance of a class - a specific realization of the class blueprint with actual values.
Q12. What is a constructor in Python?
A: The special method __init__() that is called automatically when a new object is created.
Q13. What is self in a Python class?
A: A reference to the current instance of the class, used to access its attributes and methods.
Q14. What are instance variables?
A: Variables defined inside __init__() that are unique to each object of the class.
Q15. What are class variables?
A: Variables defined directly inside the class body, shared across all objects of that class.
Q16. What is the difference between instance and class variables?
A: Instance variables are object-specific and defined in __init__; class variables are common to all
instances and defined in the class body.
Q17. What is a string in Python?
A: An immutable sequence of Unicode characters enclosed in single, double, or triple quotes.
Q18. What does the upper() method do?
A: Converts all characters in the string to uppercase.
Q19. What does the lower() method do?
A: Converts all characters in the string to lowercase.
Q20. What does the split() method do?
A: Splits a string into a list of substrings based on a specified delimiter.
Q21. What does the join() method do?
A: Joins elements of an iterable into a single string using a specified separator string.
Q22. What does the replace() method do?
A: Replaces all occurrences of a specified substring with another substring.
Q23. What does len('Python') return?
A: 6 - the number of characters in the string.
Q24. What is string slicing?
A: Extracting a portion of a string using the syntax string[start:end:step].
Q25. What is string concatenation?
A: Combining two or more strings using the + operator.
Q26. What is file handling in Python?
A: The ability to create, read, write, and close files stored on disk using Python code.
Q27. What does file mode r mean?
A: Opens the file for reading only. Raises an error if the file does not exist.
Q28. What does file mode w mean?
A: Opens the file for writing. Creates a new file or overwrites existing content.
Q29. What does file mode a mean?
A: Opens the file for appending. Adds new content without deleting existing data.
Q30. Which Python function is used to open a file?
A: open() - e.g., open('[Link]', 'r').
Q31. What does the read() method do?
A: Reads and returns the entire content of a file as a single string.
Q32. What does the readline() method do?
A: Reads and returns one line at a time from a file.
Q33. What does the write() method do?
A: Writes a specified string to the file.
Q34. What is exception handling in Python?
A: A mechanism to catch and handle runtime errors gracefully without crashing the program.
Q35. What is the purpose of the try block?
A: Contains the code that may potentially raise an exception during execution.
Q36. What is the purpose of the except block?
A: Catches and handles the exception raised in the try block.
Q37. What does the finally block do?
A: Always executes after try and except, regardless of whether an exception occurred or not.
Q38. What is a module in Python?
A: A file containing Python definitions, functions, classes, and statements that can be imported and
reused.
Q39. How do you import a module in Python?
A: Using the import keyword - e.g., import math or from math import sqrt.
Q40. Name two commonly used built-in Python libraries.
A: math (mathematical functions) and os (operating system interface functions).
UNIT 3 - FOUNDATIONS OF DATA SCIENCE
Introduction | Data Science Process | Data Preparation | EDA | Data Systems

Q1. What is Data Science?


A: An interdisciplinary field that uses scientific methods, algorithms, and systems to extract knowledge
and insights from structured and unstructured data.
Q2. Who is a Data Scientist?
A: A professional who collects, processes, analyses, and interprets large amounts of data to support
decision-making.
Q3. Name two applications of Data Science in Healthcare.
A: Disease prediction and diagnosis, and medical image analysis.
Q4. Name two applications of Data Science in Business.
A: Customer segmentation and sales or demand forecasting.
Q5. Name two applications of Data Science in Artificial Intelligence.
A: Natural language processing (NLP) and computer vision.
Q6. What is the first step in the Data Science process?
A: Defining the problem - clearly stating the question or goal to be answered.
Q7. What is data collection?
A: Gathering raw data from various sources such as databases, APIs, surveys, or web scraping.
Q8. What is data preparation?
A: The process of cleaning, transforming, and organising raw data into a format suitable for analysis.
Q9. What is data analysis?
A: Examining datasets to find patterns, trends, correlations, and relationships.
Q10. What is data modeling?
A: Building mathematical or statistical models from data to make predictions or decisions.
Q11. What is data visualization?
A: Representing data findings graphically using charts, plots, and dashboards for easier understanding.
Q12. What is data cleaning?
A: The process of detecting and correcting errors, duplicates, and inconsistencies in a dataset.
Q13. What are missing values in a dataset?
A: Absent or null entries where data was not recorded or is unavailable.
Q14. What is data transformation?
A: Converting data from one format, structure, or scale into another to make it suitable for analysis.
Q15. What is noise in data?
A: Random, irrelevant variations or errors in data that can obscure true patterns.
Q16. What are outliers in a dataset?
A: Data points that deviate significantly from the majority of the dataset and may skew analysis results.
Q17. What are anomalies in data?
A: Unusual or unexpected patterns that do not conform to the expected behaviour of the dataset.
Q18. What is the difference between noise and outliers?
A: Noise is random error distributed throughout the data; outliers are specific extreme data points.
Q19. What is EDA?
A: Exploratory Data Analysis - an approach to analysing datasets to summarise main characteristics,
often using visual methods.
Q20. What is the purpose of EDA?
A: To understand data structure, spot anomalies, identify patterns, and guide further analysis or modeling.
Q21. What are summary statistics?
A: Numerical measures such as mean, median, mode, variance, and standard deviation that describe a
dataset.
Q22. What is Data Mining?
A: The process of discovering patterns, correlations, and anomalies within large datasets using statistical
and computational techniques.
Q23. What is Data Warehousing?
A: A centralised system for storing and managing large volumes of structured historical data to support
reporting and analysis.
Q24. What is structured data?
A: Data organised in a fixed format such as rows and columns in a relational database or spreadsheet.
Q25. What is unstructured data?
A: Data with no predefined format or structure, such as text documents, images, audio, and video.
Q26. What is semi-structured data?
A: Data that has some organisational properties but does not fit into a rigid tabular structure, e.g., JSON,
XML.
Q27. What is Big Data?
A: Extremely large and complex datasets that exceed the capacity of traditional data processing tools.
Q28. What are the 3 Vs of Big Data?
A: Volume (size of data), Velocity (speed of data generation), and Variety (types of data).
Q29. What is a data pipeline?
A: A series of automated steps that move, transform, and process data from source to destination.
Q30. What is machine learning in the context of Data Science?
A: A technique where algorithms learn patterns from data to make predictions without being explicitly
programmed.
Q31. What is predictive analytics?
A: The use of historical data, statistical models, and machine learning to forecast future outcomes.
Q32. What is the difference between Data Science and Data Analytics?
A: Data Science focuses on building predictive models; Data Analytics focuses on interpreting historical
data to answer specific questions.
Q33. What is feature engineering?
A: The process of creating new input features from existing data using domain knowledge to improve
model performance.
Q34. What is a dataset?
A: A structured collection of related data values organised for analysis or processing.
Q35. What is the difference between a population and a sample?
A: A population is the entire group under study; a sample is a smaller subset selected to represent that
population.
Q36. What is data aggregation?
A: Collecting and combining data from multiple sources into a single, unified dataset or summary.
Q37. What is cross-validation?
A: A model evaluation technique that splits data into training and testing sets multiple times to measure
how well a model generalises.
Q38. What is the role of visualisation in Data Science?
A: To communicate data insights clearly and intuitively through graphical representations.
Q39. What is a data frame?
A: A two-dimensional, tabular data structure with rows and columns, commonly used in Pandas for data
analysis.
Q40. Name two popular tools or languages used in Data Science.
A: Python and R.
UNIT 4 - DESCRIPTIVE ANALYTICS (VERY IMPORTANT)
Types of Data | Statistical Measures | Normal Distribution | Correlation | Regression

Q1. What is Descriptive Analytics?


A: A branch of analytics that summarises and describes historical data to understand what has happened.
Q2. What is qualitative (categorical) data?
A: Data that represents categories or labels and cannot be measured numerically, e.g., gender, colour.
Q3. What is quantitative (numerical) data?
A: Data expressed in numbers that can be measured or counted, e.g., height, temperature, marks.
Q4. What is discrete data?
A: Numerical data that can only take specific, countable values, e.g., number of students in a class.
Q5. What is continuous data?
A: Numerical data that can take any value within a range, e.g., weight, temperature, time.
Q6. What is the Mean?
A: The arithmetic average calculated by dividing the sum of all values by the number of values.
Q7. Write the formula for Mean.
A: Mean = (Sum of all values) divided by (Number of values).
Q8. What is the Median?
A: The middle value of a dataset when all values are arranged in ascending or descending order.
Q9. How is the Median calculated when there is an even number of values?
A: By taking the average (mean) of the two middle values.
Q10. What is the Mode?
A: The value that appears most frequently in a dataset. A dataset can have no mode, one mode, or
multiple modes.
Q11. What are Measures of Central Tendency?
A: Statistical values that describe the centre or typical value of a dataset: Mean, Median, and Mode.
Q12. What is the Range in statistics?
A: The difference between the maximum and minimum values in a dataset. Range = Maximum -
Minimum.
Q13. What is Variance?
A: The average of the squared differences of each data point from the mean, measuring data spread.
Q14. What is Standard Deviation?
A: The square root of variance. It measures how spread out data values are around the mean.
Q15. What are Measures of Dispersion?
A: Statistical measures that describe the spread or variability in a dataset: Range, Variance, and Standard
Deviation.
Q16. What is the difference between variance and standard deviation?
A: Variance is the average squared deviation from the mean; standard deviation is its square root and is in
the same unit as the original data.
Q17. What is a frequency table?
A: A table that shows how often each value or category appears in a dataset.
Q18. Which type of graph is used to represent categorical data?
A: Bar chart or pie chart.
Q19. What is a histogram used for?
A: To show the frequency distribution of continuous numerical data using adjacent rectangular bars.
Q20. What is a Normal Distribution?
A: A symmetric, bell-shaped probability distribution where most data is concentrated around the mean.
Q21. What does the Bell Curve represent?
A: A graphical depiction of a normal distribution, symmetric about the mean with tails extending on both
sides.
Q22. What is a Z-score?
A: A value indicating how many standard deviations a data point is from the mean. Formula: Z = (X -
Mean) divided by Standard Deviation.
Q23. What does a Z-score of 0 indicate?
A: The data point is exactly at the mean.
Q24. What percentage of data falls within one standard deviation in a normal distribution?
A: Approximately 68% of data.
Q25. What is Correlation?
A: A statistical measure describing the strength and direction of the linear relationship between two
variables.
Q26. What is positive correlation?
A: When one variable increases, the other variable also increases - both move in the same direction.
Q27. What is negative correlation?
A: When one variable increases, the other variable decreases - they move in opposite directions.
Q28. What is the Correlation Coefficient?
A: A numerical value between -1 and +1 that quantifies the strength and direction of the correlation
between two variables.
Q29. What does a correlation coefficient of +1 indicate?
A: A perfect positive correlation - the two variables move together completely in the same direction.
Q30. What does a correlation coefficient of -1 indicate?
A: A perfect negative correlation - the two variables move in exactly opposite directions.
Q31. What does a correlation coefficient of 0 indicate?
A: No linear relationship exists between the two variables.
Q32. What is Regression in statistics?
A: A statistical technique used to model and quantify the relationship between a dependent variable and
one or more independent variables.
Q33. What is Linear Regression?
A: A regression method that models the relationship between two variables using a straight line described
by the equation y = mx + c.
Q34. What is the Regression Line?
A: The best-fit straight line through a scatter plot that minimises the overall distance between data points
and the line.
Q35. What is the Least Squares Method?
A: A technique used to find the best-fit regression line by minimising the sum of squares of the residuals
(errors).
Q36. What is a dependent variable in regression?
A: The output or response variable being predicted, usually denoted as Y.
Q37. What is an independent variable in regression?
A: The input or predictor variable used to make predictions, usually denoted as X.
Q38. What is the difference between correlation and regression?
A: Correlation measures the strength of a relationship between variables; regression models the
relationship to make predictions.
Q39. What is a scatter plot used for in analytics?
A: To visually display and analyse the relationship or correlation between two continuous numerical
variables.
Q40. What does R-squared represent in regression?
A: The proportion of variance in the dependent variable explained by the independent variable(s). It
ranges from 0 to 1.
UNIT 5 - NUMPY AND PANDAS
NumPy Arrays | Array Operations | Array Functions | Pandas Series and DataFrame | Data Operations | Data
Cleaning

Q1. What is NumPy?


A: NumPy (Numerical Python) is a Python library for numerical computing that provides support for large
multi-dimensional arrays, matrices, and mathematical functions.
Q2. What is the core data structure of NumPy?
A: ndarray - an N-dimensional array object.
Q3. How do you create a NumPy array?
A: Using [Link]() - e.g., [Link]([1, 2, 3]) creates a 1D array.
Q4. What is a 1D array in NumPy?
A: A one-dimensional array with a single row of elements, similar to a list.
Q5. What is a 2D array in NumPy?
A: A two-dimensional array with rows and columns, similar to a matrix or table.
Q6. What is a multi-dimensional array in NumPy?
A: An array with more than two dimensions used for complex data such as 3D images.
Q7. How do you find the shape of a NumPy array?
A: Using the .shape attribute - e.g., [Link] returns a tuple like (rows, columns).
Q8. What does the reshape() function do in NumPy?
A: Changes the shape of a NumPy array without altering its data.
Q9. What is array indexing in NumPy?
A: Accessing individual elements of an array using their position index, starting from 0.
Q10. What is array slicing in NumPy?
A: Extracting a portion of an array using the syntax arr[start:stop:step].
Q11. How do you iterate over a NumPy array?
A: Using a for loop - e.g., for x in arr: print(x).
Q12. What does [Link]() do?
A: Joins two or more arrays along a specified axis.
Q13. What does [Link]() do?
A: Splits an array into multiple sub-arrays along a specified axis.
Q14. What does [Link]() do?
A: Returns a sorted copy of the array in ascending order by default.
Q15. What does [Link]() do?
A: Returns the indices of elements that satisfy a given condition.
Q16. What does [Link]() do?
A: Creates an independent copy of an array so that changes do not affect the original.
Q17. What is the difference between a view and a copy in NumPy?
A: A view shares memory with the original array and changes affect the original; a copy is completely
independent.
Q18. What does [Link]() create?
A: An array filled entirely with zeros of a specified shape.
Q19. What does [Link]() create?
A: An array filled entirely with ones of a specified shape.
Q20. What does [Link]() do?
A: Creates an array with evenly spaced values within a specified range, similar to Python's range()
function.
Q21. What is Pandas?
A: An open-source Python library for data manipulation and analysis, built on top of NumPy.
Q22. What is a Pandas Series?
A: A one-dimensional labelled array capable of holding data of any type, with a default or custom index.
Q23. What is a Pandas DataFrame?
A: A two-dimensional labelled data structure with rows and named columns, similar to a spreadsheet or
SQL table.
Q24. How do you create a Pandas DataFrame?
A: Using [Link]() - e.g., [Link]({'A': [1,2], 'B': [3,4]}).
Q25. How do you access a column in a Pandas DataFrame?
A: Using df['column_name'] or df.column_name.
Q26. How do you access a row by label in Pandas?
A: Using [Link][label] for label-based indexing.
Q27. How do you access a row by position in Pandas?
A: Using [Link][position] for integer position-based indexing.
Q28. What does [Link]() do in Pandas?
A: Returns the first 5 rows of a DataFrame, or a specified number of rows.
Q29. What does [Link]() do in Pandas?
A: Returns the last 5 rows of a DataFrame, or a specified number of rows.
Q30. How do you filter rows in a Pandas DataFrame?
A: Using a Boolean condition - e.g., df[df['Age'] > 25] returns rows where Age exceeds 25.
Q31. How do you sort a DataFrame by a column?
A: Using df.sort_values('column_name'). Add ascending=False for descending order.
Q32. How do you rank values in a Pandas Series?
A: Using [Link]() which assigns a rank to each element based on its value.
Q33. What does [Link]() do?
A: Returns a DataFrame of the same shape with True where values are missing (NaN) and False
elsewhere.
Q34. What does [Link]() do?
A: Removes all rows or columns that contain at least one missing NaN value.
Q35. What does [Link](value) do?
A: Replaces all missing NaN values in the DataFrame with the specified replacement value.
Q36. What does [Link]() do?
A: Generates summary statistics including count, mean, std, min, max, and quartiles for numerical
columns.
Q37. What does [Link]() do?
A: Prints a concise summary of the DataFrame including column names, data types, and non-null counts.
Q38. What does [Link]() do?
A: Groups the DataFrame by one or more columns to allow aggregate operations like sum, mean, or
count.
Q39. What does [Link]() do?
A: Combines two DataFrames based on a common column or index, similar to a SQL JOIN operation.
Q40. What is data alignment in Pandas?
A: The automatic alignment of data based on index labels when performing operations between two
Series or DataFrames.
UNIT 6 - DATA VISUALIZATION
Matplotlib | Graph Types | Graph Components | Seaborn | Special Plots | 3D Plots

Q1. What is Data Visualization?


A: The graphical representation of data and information using charts, graphs, and plots to identify trends,
patterns, and insights.
Q2. What is Matplotlib?
A: A comprehensive Python library for creating static, animated, and interactive 2D visualisations.
Q3. How do you import Matplotlib in Python?
A: import [Link] as plt
Q4. What function is used to display a plot in Matplotlib?
A: [Link]()
Q5. What is a Line Plot used for?
A: To display trends or changes in data over a continuous interval or time period.
Q6. What is a Bar Chart used for?
A: To compare discrete categories or groups using rectangular bars of varying heights or lengths.
Q7. What is a Pie Chart used for?
A: To show the proportional distribution of categories as slices of a circle representing parts of a whole.
Q8. What is a Histogram used for?
A: To display the frequency distribution of continuous numerical data using adjacent rectangular bars.
Q9. What is a Box Plot used for?
A: To display the distribution of data using the five-number summary: minimum, Q1, median, Q3, and
maximum.
Q10. What is a Scatter Plot used for?
A: To show the relationship or correlation between two continuous numerical variables.
Q11. How do you create a line plot in Matplotlib?
A: [Link](x, y) followed by [Link]().
Q12. How do you create a bar chart in Matplotlib?
A: [Link](categories, values) followed by [Link]().
Q13. How do you create a pie chart in Matplotlib?
A: [Link](sizes, labels=labels) followed by [Link]().
Q14. How do you create a histogram in Matplotlib?
A: [Link](data, bins=n) followed by [Link]().
Q15. What is a subplot in Matplotlib?
A: Multiple plots displayed together in a single figure using [Link]() or [Link]().
Q16. How do you add a title to a Matplotlib plot?
A: [Link]('Your Title')
Q17. How do you label the x-axis in Matplotlib?
A: [Link]('X-axis Label')
Q18. How do you label the y-axis in Matplotlib?
A: [Link]('Y-axis Label')
Q19. What is a legend in a plot?
A: A key that identifies and explains the different data series or elements shown in the plot.
Q20. How do you add a legend in Matplotlib?
A: [Link]() - requires the label parameter to be set in the plot functions.
Q21. What does [Link]() do in Matplotlib?
A: Adds a reference grid of horizontal and vertical lines to the background of the plot.
Q22. How do you set the size of a Matplotlib figure?
A: [Link](figsize=(width, height)) - e.g., [Link](figsize=(10, 6)).
Q23. What is Seaborn?
A: A Python data visualisation library built on top of Matplotlib that provides a higher-level interface and
more attractive default styles.
Q24. How do you import Seaborn in Python?
A: import seaborn as sns
Q25. What is the advantage of Seaborn over Matplotlib?
A: Seaborn provides more aesthetically pleasing defaults, built-in themes, and specialised statistical plots
with less code.
Q26. What is a Pair Plot in Seaborn?
A: A grid of scatter plots showing pairwise relationships between all numerical variables in a dataset.
Q27. How do you create a pair plot in Seaborn?
A: [Link](dataframe)
Q28. What is a Heatmap in Seaborn?
A: A colour-coded matrix visualisation used to show the magnitude of values and correlation between
variables.
Q29. How do you create a heatmap in Seaborn?
A: [Link](data, annot=True)
Q30. What is a 3D plot in Matplotlib?
A: A three-dimensional visualisation created using the mpl_toolkits.mplot3d module.
Q31. How do you enable 3D plotting in Matplotlib?
A: from mpl_toolkits.mplot3d import Axes3D, then use fig.add_subplot(111, projection='3d').
Q32. What is the difference between a bar chart and a histogram?
A: Bar charts display categorical data with gaps between bars; histograms display continuous numerical
data with no gaps between bars.
Q33. What does the bins parameter do in a histogram?
A: It specifies the number of intervals (bars) used to group the continuous data.
Q34. What is a violin plot?
A: A combination of a box plot and KDE plot that shows both the distribution and probability density of
data.
Q35. What is a KDE plot?
A: Kernel Density Estimate plot - a smoothed continuous curve that estimates the probability density of a
variable.
Q36. What does sns.set_theme() do?
A: Sets the aesthetic theme including style, colour palette, and font for all subsequent Seaborn plots.
Q37. What are the main components of a complete Matplotlib figure?
A: Figure, axes, title, x-axis label, y-axis label, legend, tick marks, and grid.
Q38. What is [Link]() used for?
A: To save the current plot to a file - e.g., [Link]('[Link]') saves it as a PNG image.
Q39. What is the purpose of the color parameter in Matplotlib?
A: To specify the colour of plotted lines, bars, or markers in the chart.
Q40. What is an area plot?
A: A line plot where the area below the line is filled with colour, used to show cumulative totals or volume
over time.

End of Complete Question and Answer Bank | 6 Units | 240 Questions Total
Tip: Pay extra attention to Unit 4 (Descriptive Analytics) - marked as Very Important!

You might also like