🌍 freeCodeCamp · flashcards
freeCodeCamp Data Analysis with Python Flashcards
50 question-and-answer cards covering Data Analysis with Python as it is examined in freeCodeCamp. 24 of them are printed below, taken from across the deck — no signup, no paywall on the preview.
24 sample cards from the Data Analysis with Python deck
Sampled from the end of the deck, so these are different cards from the ones shown on the syllabus page.
Which pandas functions read and write CSV files, and how do you avoid writing the index?
pd.read_csv('file.csv') reads (key params: sep, header, names, index_col, parse_dates, na_values); df.to_csv('file.csv', index=False) writes without the row index column.
In pd.read_csv, what do the parameters index_col, parse_dates, and na_values do?
index_col sets a column as the DataFrame index; parse_dates converts the listed columns to datetime64; na_values specifies extra strings (e.g., '?', 'N/A') to treat as NaN on load.
Besides CSV, name three other data formats pandas can read and their functions.
Excel: pd.read_excel (sheet_name selects a sheet); JSON: pd.read_json; SQL: pd.read_sql with a database connection; also read_html for HTML tables and read_parquet. Each has a matching to_* writer method.
In Matplotlib, what is the difference between a Figure and an Axes?
The Figure is the whole canvas/window that can contain one or more plots; an Axes is a single plot area with its own x-axis, y-axis, title, and data. fig, ax = plt.subplots() creates one figure with one axes; plt.subplots(2, 2) creates a $2 \times 2$ grid of axes.
Which Matplotlib functions create a line plot, scatter plot, bar chart, and histogram?
plt.plot(x, y) — line; plt.scatter(x, y) — scatter; plt.bar(x, height) — bar chart (barh for horizontal); plt.hist(data, bins=n) — histogram of a distribution.
How do you add a title, axis labels, and a legend to a Matplotlib plot?
plt.title('...') (or ax.set_title), plt.xlabel('...') and plt.ylabel('...') (or ax.set_xlabel/set_ylabel), and plt.legend() after giving each plotted series a label= argument. plt.savefig('name.png') saves the figure to a file.
What is the difference between Matplotlib's pyplot (state-based) interface and the object-oriented interface?
pyplot (plt.plot, plt.title) implicitly operates on the 'current' figure/axes — convenient for quick plots; the object-oriented interface creates explicit objects (fig, ax = plt.subplots(); ax.plot(...); ax.set_title(...)), which is clearer and required when managing multiple subplots.
What is Seaborn and how does it relate to Matplotlib?
Seaborn is a statistical visualization library built ON TOP of Matplotlib. It provides high-level functions that work directly with pandas DataFrames (data=, x=, y=, hue= arguments), attractive default styles, and automatic aggregation/statistical estimation; the output is still Matplotlib figures/axes that can be customized with Matplotlib calls.
What does the hue parameter do in Seaborn plotting functions?
hue maps a categorical (or numeric) column to COLOR, splitting the plot into one colored group per category with an automatic legend — e.g., sns.scatterplot(data=df, x='age', y='income', hue='gender') colors points by gender.
Which Seaborn functions visualize a distribution, a category-vs-value comparison, and a correlation matrix?
Distribution: sns.histplot or sns.kdeplot (sns.displot is the figure-level version); category comparisons: sns.boxplot, sns.barplot (bar height = mean with a confidence interval), sns.countplot (frequencies); correlation matrix: sns.heatmap(df.corr(), annot=True) with colors encoding values.
In Seaborn, what is the difference between catplot (figure-level) and boxplot/barplot (axes-level) functions?
Axes-level functions draw onto a single Matplotlib Axes and can be placed in existing subplots; figure-level functions like catplot, relplot, and displot create their own figure and support faceting with col= and row= to produce a grid of subplots split by category. catplot's kind= parameter ('bar', 'box', 'count', ...) selects the underlying plot.
freeCodeCamp Mean-Variance-Std Calculator: what must the calculate() function do with its input, and when must it raise an error?
It takes a list of exactly 9 numbers, converts it to a $3 \times 3$ NumPy array, and returns a dictionary with mean, variance, standard deviation, max, min, and sum — each computed along axis=0 (columns), axis=1 (rows), and for the flattened array (values as lists). If the list does not contain 9 numbers it must raise a ValueError with the message 'List must contain nine numbers.'
State the formulas for population variance and standard deviation used by np.var and np.std (default ddof=0).
Variance: $$\sigma^{2} = \frac{1}{N} \sum_{i=1}^{N} (x_{i} - \mu)^{2}$$ where $\mu = \frac{1}{N}\sum_{i=1}^{N} x_{i}$. Standard deviation: $\sigma = \sqrt{\sigma^{2}}$. By default NumPy divides by $N$ (population); ddof=1 gives the sample version dividing by $N-1$.
How do you convert a flat list of 9 numbers into the $3 \times 3$ array needed for the Mean-Variance-Std Calculator?
np.array(list).reshape(3, 3) — np.array converts the list to an ndarray and reshape(3, 3) reorganizes it into 3 rows and 3 columns (row-major order: the first three values become row 0).
Demographic Data Analyzer: how do you compute the percentage of people with a Bachelor's degree from the census DataFrame?
Filter with a boolean mask and use the mask's mean or length ratio: $$\text{pct} = \frac{(\text{df['education']} == \text{'Bachelors'}).sum()}{\text{len(df)}} \times 100$$ rounded to 1 decimal — the standard count-matching-rows / total-rows pattern used throughout the project.
Demographic Data Analyzer: how do you find the country with the highest percentage of people earning >50K?
Compute per-country rich counts over per-country totals with value_counts (or groupby): rich_pct = df[df['salary'] == '>50K']['native-country'].value_counts() / df['native-country'].value_counts() * 100, then take .idxmax() for the country name and .max() for the percentage.
In pandas, what is the difference between idxmax() and max()?
max() returns the largest VALUE in a Series; idxmax() returns the INDEX LABEL where that maximum occurs — e.g., in the Demographic Data Analyzer, series.idxmax() gives the country name while series.max() gives its percentage. (idxmin/min are the analogues for the smallest value.)
Medical Data Visualizer: how are the overweight and BMI defined, and how are cholesterol/gluc normalized?
BMI $= \frac{\text{weight (kg)}}{\text{height (m)}^{2}}$; overweight $= 1$ if BMI $> 25$, else $0$. Cholesterol and gluc are normalized so 0 = good and 1 = bad: value 1 becomes 0, values $> 1$ become 1.
Medical Data Visualizer: what do pd.melt and sns.catplot do in the categorical plot step?
pd.melt reshapes the DataFrame from wide to long format — the six lifestyle columns (cholesterol, gluc, smoke, alco, active, overweight) become variable/value pairs with 'cardio' kept as id_vars. sns.catplot(kind='count', x='variable', hue='value', col='cardio') then draws count bars for each variable, split by value, in separate panels for cardio = 0 and 1.
Medical Data Visualizer: how is the data cleaned before the correlation heatmap, and how is only the lower triangle shown?
Keep rows where ap_lo $\leq$ ap_hi and where height and weight lie within the 2.5th–97.5th percentiles (df['height'].quantile(0.025) to quantile(0.975)). Then compute corr = df.corr(), build a mask with np.triu(np.ones_like(corr, dtype=bool)) to hide the upper triangle, and draw sns.heatmap(corr, mask=mask, annot=True, fmt='.1f').
Page View Time Series Visualizer: how is the data cleaned before plotting?
Load fcc-forum-pageviews.csv with the date column parsed as datetime and set as the index, then filter OUT the extreme days: keep only rows where page views are between the 2.5th and 97.5th percentiles, i.e., df[(df['value'] >= df['value'].quantile(0.025)) & (df['value'] <= df['value'].quantile(0.975))].
Page View Time Series Visualizer: what three plots does the project require and what does each show?
(1) Line plot of daily page views over time; (2) bar plot of the AVERAGE daily page views for each month grouped by year (df.groupby([year, month]).mean(), legend of month names); (3) two side-by-side box plots — year-wise (trend across years) and month-wise (seasonality Jan–Dec) — built from a long-format DataFrame with sns.boxplot.
Sea Level Predictor: what does scipy.stats.linregress return, and how is the line of best fit used to predict sea level in 2050?
linregress(x, y) returns slope, intercept, rvalue, pvalue, and stderr for the least-squares line $$y = \text{slope} \cdot x + \text{intercept}.$$ The prediction plugs in the year: sea level in 2050 $\approx \text{slope} \times 2050 + \text{intercept}$; the fitted line is plotted over a scatter of the CSIRO data.
Sea Level Predictor: why are TWO regression lines fitted, and over what ranges are they drawn?
The first line uses ALL data (from 1880) to show the long-term trend; the second uses only data from year 2000 onward to capture the recent, steeper rate of rise. Both lines are extended to 2050 to compare predictions — the recent-data line predicts a higher 2050 sea level, showing the rate of rise has increased.
What this deck covers
The Data Analysis with Python deck follows the freeCodeCamp Data Analysis with Python syllabus — 4 chapters and 14 topics — so questions land on material that is genuinely examinable rather than trivia around it. That works out to roughly 12.5 cards per chapter.
Answers are written to be recallable, not just readable — averaging about 272 characters, which is long enough to carry the reasoning and short enough to say out loud.
A deck like this earns its keep on the second and third pass. Read the syllabus first so you know the shape of the subject, then use the cards to find the specific facts that have not stuck.
Data Analysis with Python flashcards FAQ
How many Data Analysis with Python flashcards are in this freeCodeCamp deck?
50 cards. This page previews 24 of them, sampled evenly across the deck so you can judge the difficulty before installing anything.
Are these freeCodeCamp flashcards free?
Yes. The preview here is free to read with no signup, and the full 50-card deck is free inside the Examius app.
What do the Data Analysis with Python cards cover?
They follow the freeCodeCamp Data Analysis with Python syllabus — 4 chapters and 14 topics — so the questions track what is actually examinable.
How should I use these flashcards?
Read the syllabus first so you know the shape of the subject, then drill the deck. Examius schedules each card with spaced repetition, so cards you keep missing come back sooner and ones you know drift further apart.