0
0
Data Analysis Pythondata~20 mins

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

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Line Plot Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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()
AA bar chart with bars at x=1 to 4 with heights 10 to 30
BA line plot showing points connected by a line from (1,10) to (4,30)
CA scatter plot showing only points at (1,10), (2,20), (3,25), (4,30) without lines
DAn empty plot with no data shown
Attempts:
2 left
💡 Hint
plt.plot() connects points with lines by default.
data_output
intermediate
2: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()
A2
B4
C3
D1
Attempts:
2 left
💡 Hint
Each plt.plot() call adds one line to the plot.
🔧 Debug
advanced
2: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()
ANo error, plot will display correctly
BTypeError: unsupported operand type(s) for +
CSyntaxError: invalid syntax
DValueError: x and y must have same first dimension
Attempts:
2 left
💡 Hint
x and y lists must be the same length for plotting.
visualization
advanced
2: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()
ANo line, only points shown
BA solid line connecting the points
CA dashed line connecting the points
DA dotted line connecting the points
Attempts:
2 left
💡 Hint
The linestyle='--' means dashed line.
🚀 Application
expert
3: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?
ASales generally increased over the year but dropped in July
BSales decreased steadily all year
CSales were constant all year with no changes
DSales peaked in July and dropped afterwards
Attempts:
2 left
💡 Hint
Look at the slope and dips in the line plot.