Challenge - 5 Problems
Line Plot Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of a simple line plot code
What will be the output of this Python code using matplotlib?
Data Analysis Python
import matplotlib.pyplot as plt x = [1, 2, 3, 4] y = [10, 20, 25, 30] plt.plot(x, y) plt.show()
Attempts:
2 left
💡 Hint
plt.plot() connects points with lines by default.
✗ Incorrect
The plt.plot() function draws a line plot connecting the points defined by x and y lists.
❓ data_output
intermediate2:00remaining
Number of lines in a multi-line plot
Given this code, how many separate lines will appear in the plot?
Data Analysis Python
import matplotlib.pyplot as plt x = [0, 1, 2, 3] y1 = [1, 3, 2, 4] y2 = [4, 2, 3, 1] plt.plot(x, y1) plt.plot(x, y2) plt.show()
Attempts:
2 left
💡 Hint
Each plt.plot() call adds one line to the plot.
✗ Incorrect
Two plt.plot() calls create two separate lines on the same plot.
🔧 Debug
advanced2:00remaining
Identify the error in this line plot code
What error will this code produce when run?
Data Analysis Python
import matplotlib.pyplot as plt x = [1, 2, 3] y = [4, 5] plt.plot(x, y) plt.show()
Attempts:
2 left
💡 Hint
x and y lists must be the same length for plotting.
✗ Incorrect
The x list has 3 elements but y has 2, causing a ValueError.
❓ visualization
advanced2:00remaining
Effect of linestyle parameter in line plots
Which option shows the correct line style for this code?
Data Analysis Python
import matplotlib.pyplot as plt x = [0, 1, 2, 3] y = [3, 1, 4, 2] plt.plot(x, y, linestyle='--') plt.show()
Attempts:
2 left
💡 Hint
The linestyle='--' means dashed line.
✗ Incorrect
The linestyle parameter '--' creates a dashed line style.
🚀 Application
expert3:00remaining
Interpreting trends from a line plot
A line plot shows monthly sales over a year with a steady upward slope except for a dip in July. What does this indicate?
Attempts:
2 left
💡 Hint
Look at the slope and dips in the line plot.
✗ Incorrect
An upward slope means increasing sales; a dip in July means a temporary drop.