Bird
Raised Fist0
Data Analysis Pythondata~20 mins

Essential libraries overview (Pandas, NumPy, Matplotlib) in Data Analysis Python - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Essential Libraries Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
2:00remaining
What is the output of this NumPy array operation?
Consider the following code that uses NumPy to create and manipulate arrays. What will be printed?
Data Analysis Python
import numpy as np
arr = np.array([1, 2, 3, 4])
result = arr * 2 + 1
print(result)
A[3 5 7 9]
B[2 4 6 8]
C[1 2 3 4]
D[4 6 8 10]
Attempts:
2 left
💡 Hint
Remember that NumPy applies operations element-wise on arrays.
❓ data_output
intermediate
2:00remaining
What does this Pandas DataFrame look like after filtering?
Given this DataFrame, what rows remain after filtering for values greater than 50 in column 'B'?
Data Analysis Python
import pandas as pd
df = pd.DataFrame({'A': [10, 20, 30, 40], 'B': [45, 55, 65, 35]})
filtered_df = df[df['B'] > 50]
print(filtered_df)
A
   A   B
1  20  55
2  30  65
B
   A   B
0  10  45
3  40  35
C
   A   B
1  20  55
3  40  35
D
   A   B
0  10  45
2  30  65
Attempts:
2 left
💡 Hint
Look for rows where column 'B' has values strictly greater than 50.
❓ visualization
advanced
2:00remaining
What kind of plot does this Matplotlib code produce?
Look at this Matplotlib code. What type of plot will it create?
Data Analysis Python
import matplotlib.pyplot as plt
x = [1, 2, 3, 4]
y = [10, 20, 25, 30]
plt.bar(x, y)
plt.show()
AA pie chart showing proportions of values 10, 20, 25, 30
BA line plot connecting points (1,10), (2,20), (3,25), (4,30)
CA bar chart with bars at positions 1 to 4 and heights 10, 20, 25, 30
DA scatter plot with points at (1,10), (2,20), (3,25), (4,30)
Attempts:
2 left
💡 Hint
The function plt.bar creates vertical bars.
🧠 Conceptual
advanced
1:30remaining
Which library is best suited for fast numerical operations on arrays?
You want to perform fast mathematical operations on large arrays of numbers. Which library is designed specifically for this?
ASeaborn
BMatplotlib
CPandas
DNumPy
Attempts:
2 left
💡 Hint
Think about which library provides efficient array objects and math functions.
🔧 Debug
expert
2:00remaining
What error does this Pandas code raise?
This code tries to select a column from a DataFrame but causes an error. What error is raised?
Data Analysis Python
import pandas as pd
df = pd.DataFrame({'X': [1, 2], 'Y': [3, 4]})
print(df['Z'])
ATypeError
BKeyError
CValueError
DAttributeError
Attempts:
2 left
💡 Hint
The column 'Z' does not exist in the DataFrame.

Practice

(1/5)
1. Which library is mainly used to organize data in tables for easy analysis?
easy
A. Seaborn
B. NumPy
C. Matplotlib
D. Pandas

Solution

  1. Step 1: Understand library purposes

    Pandas is designed to organize data in tables called DataFrames.
  2. Step 2: Match library to task

    Since the question asks about organizing data in tables, Pandas fits best.
  3. Final Answer:

    Pandas -> Option D
  4. Quick Check:

    Tables = Pandas [OK]
Hint: Tables mean Pandas, numbers mean NumPy, charts mean Matplotlib [OK]
Common Mistakes:
  • Confusing NumPy with Pandas for table data
  • Thinking Matplotlib organizes data
  • Choosing Seaborn which is for visualization, not tables
2. Which of the following is the correct way to import NumPy in Python?
easy
A. import matplotlib.pyplot as plt
B. import pandas as pd
C. import numpy as np
D. import numpy as pd

Solution

  1. Step 1: Recall standard import conventions

    NumPy is commonly imported as 'np' to shorten code.
  2. Step 2: Check each option

    import numpy as np uses 'import numpy as np' which is correct; others are for different libraries or wrong aliases.
  3. Final Answer:

    import numpy as np -> Option C
  4. Quick Check:

    NumPy alias = np [OK]
Hint: NumPy is always imported as np [OK]
Common Mistakes:
  • Using wrong alias like pd for NumPy
  • Mixing import statements of different libraries
  • Forgetting 'as' keyword
3. What will be the output of this code?
import numpy as np
arr = np.array([1, 2, 3])
print(arr * 2)
medium
A. [2 4 6]
B. [1 2 3 1 2 3]
C. [3 4 5]
D. Error

Solution

  1. Step 1: Understand NumPy array multiplication

    Multiplying a NumPy array by a number multiplies each element by that number.
  2. Step 2: Calculate element-wise multiplication

    Each element in [1, 2, 3] multiplied by 2 gives [2, 4, 6].
  3. Final Answer:

    [2 4 6] -> Option A
  4. Quick Check:

    Array * 2 doubles each element [OK]
Hint: NumPy * number multiplies each element [OK]
Common Mistakes:
  • Thinking * duplicates the array
  • Expecting element-wise addition instead of multiplication
  • Assuming syntax error
4. Find the error in this code snippet:
import matplotlib.pyplot as plt
plt.plot([1, 2, 3], [4, 5])
plt.show()
medium
A. plt.show() is missing
B. The lists have different lengths causing an error
C. Wrong import statement for matplotlib
D. No error, code runs fine

Solution

  1. Step 1: Check input lists length

    Plotting requires x and y lists to have the same length.
  2. Step 2: Identify mismatch

    Here, x has 3 elements, y has 2, causing a ValueError.
  3. Final Answer:

    The lists have different lengths causing an error -> Option B
  4. Quick Check:

    Plot lists length must match [OK]
Hint: x and y lists must be same length for plot [OK]
Common Mistakes:
  • Ignoring length mismatch
  • Thinking plt.show() is missing
  • Assuming import is wrong
5. You have a Pandas DataFrame with a column 'Age'. Which library and method would you use to quickly calculate the average age?
hard
A. Pandas' mean() method on the 'Age' column
B. Matplotlib's plot() on the 'Age' column
C. NumPy's np.mean() on the 'Age' column
D. NumPy's array() to convert 'Age' column

Solution

  1. Step 1: Identify the data structure

    The 'Age' column is part of a Pandas DataFrame.
  2. Step 2: Choose the best method for average

    Pandas columns have a built-in mean() method to calculate average quickly.
  3. Step 3: Compare options

    NumPy's np.mean() works but requires extra step; Matplotlib is for plotting, not calculation.
  4. Final Answer:

    Pandas' mean() method on the 'Age' column -> Option A
  5. Quick Check:

    DataFrame column average = mean() [OK]
Hint: Use Pandas mean() directly on DataFrame columns [OK]
Common Mistakes:
  • Using Matplotlib for calculations
  • Converting column unnecessarily with NumPy
  • Not using built-in Pandas methods
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard