Challenge - 5 Problems
Scatter Plot Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of a simple scatter plot code
What will be the output of this code snippet that uses
plt.scatter to plot points?Matplotlib
import matplotlib.pyplot as plt x = [1, 2, 3] y = [4, 5, 6] plt.scatter(x, y) plt.show()
Attempts:
2 left
💡 Hint
Remember, plt.scatter plots points, not lines or bars.
✗ Incorrect
plt.scatter plots individual points at the given x and y coordinates. It does not connect points or create bars.
❓ data_output
intermediate1:30remaining
Number of points plotted by plt.scatter
How many points will be plotted by this code?
Matplotlib
import matplotlib.pyplot as plt x = [10, 20, 30, 40] y = [1, 2, 3, 4] plt.scatter(x, y) plt.show()
Attempts:
2 left
💡 Hint
Count the number of x or y values given.
✗ Incorrect
There are 4 x values and 4 y values, so 4 points are plotted.
🔧 Debug
advanced2:00remaining
Identify the error in scatter plot code
What error will this code produce?
Matplotlib
import matplotlib.pyplot as plt x = [1, 2, 3] y = [4, 5] plt.scatter(x, y) plt.show()
Attempts:
2 left
💡 Hint
Check if x and y lists have the same length.
✗ Incorrect
plt.scatter requires x and y to have the same number of elements to pair points correctly.
❓ visualization
advanced2:00remaining
Effect of marker size in plt.scatter
What will be the visual difference when running this code compared to default marker size?
Matplotlib
import matplotlib.pyplot as plt x = [1, 2, 3] y = [4, 5, 6] plt.scatter(x, y, s=200) plt.show()
Attempts:
2 left
💡 Hint
The 's' parameter controls marker size in plt.scatter.
✗ Incorrect
Setting s=200 increases the marker size, making points bigger on the plot.
🚀 Application
expert3:00remaining
Plotting two groups with different colors using plt.scatter
Which code correctly plots two groups of points in different colors on the same scatter plot?
Attempts:
2 left
💡 Hint
Use separate plt.scatter calls with color argument for each group.
✗ Incorrect
Option B plots two groups separately with specified colors. Option B fails because color list must be a sequence of valid color specs, but matplotlib expects a single color or array of floats for colormap. Option B plots both groups with default color. Option B has invalid color string causing error.