0
0
Data Analysis Pythondata~20 mins

Scatter plots in Data Analysis Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Scatter Plot Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
1:30remaining
Scatter plot point count
What is the number of points plotted by this code?
Data Analysis Python
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(10)
y = x**2
plt.scatter(x, y)
plt.show()
print(len(x))
A0
B9
C11
D10
Attempts:
2 left
💡 Hint
Count how many elements are in the x array.
data_output
intermediate
2:00remaining
Scatter plot color array length
What happens if the color array length does not match the number of points in this scatter plot?
Data Analysis Python
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(5)
y = x * 2
colors = ['red', 'blue']
plt.scatter(x, y, c=colors)
plt.show()
AIgnores colors and plots default color
BPlots points with repeated colors
CRaises ValueError due to mismatch in colors length
DPlots only first two points with colors, others default
Attempts:
2 left
💡 Hint
Check if matplotlib requires color array length to match points.
visualization
advanced
2:30remaining
Scatter plot with size and color mapping
Which option produces a scatter plot where point size and color both vary with data?
Data Analysis Python
import matplotlib.pyplot as plt
import numpy as np
x = np.random.rand(50)
y = np.random.rand(50)
sizes = 100 * x
colors = y
plt.scatter(x, y, s=sizes, c=colors, cmap='viridis')
plt.colorbar()
plt.show()
APoints sized by x values and colored by y values with colorbar
BPoints sized by x values but all colored blue without colorbar
CPoints all same size and colored by x values without colorbar
DPoints sized by y values and colored by x values with colorbar
Attempts:
2 left
💡 Hint
Check which variables control size and color in plt.scatter.
🔧 Debug
advanced
1:30remaining
Identify error in scatter plot code
What error does this code raise?
Data Analysis Python
import matplotlib.pyplot as plt
x = [1, 2, 3]
y = [4, 5]
plt.scatter(x, y)
plt.show()
AValueError: x and y must be the same size
BTypeError: unsupported operand type(s)
CIndexError: list index out of range
DNo error, plots successfully
Attempts:
2 left
💡 Hint
Check if x and y have the same length.
🚀 Application
expert
3:00remaining
Interpreting scatter plot clustering
You have a scatter plot showing two clear clusters of points. What is the best data science interpretation?
AThe scatter plot has an error and points are misplaced
BThe data likely contains two distinct groups or categories
CThe data is uniformly distributed with no pattern
DThe data shows a linear relationship with no clusters
Attempts:
2 left
💡 Hint
Clusters in scatter plots usually indicate groups.