0
0
Matplotlibdata~10 mins

Why line plots show trends in Matplotlib - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the matplotlib plotting library.

Matplotlib
import [1] as plt
Drag options to blanks, or click blank then click option'
Amatplotlib.pyplot
Bseaborn
Cpandas
Dnumpy
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the wrong library like numpy or pandas for plotting.
Forgetting to import pyplot specifically.
2fill in blank
medium

Complete the code to plot a line graph of y values.

Matplotlib
plt.[1]([1, 2, 3, 4], [10, 20, 25, 30])
plt.show()
Drag options to blanks, or click blank then click option'
Ascatter
Bplot
Cline
Dbar
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'scatter' which only plots points without lines.
Using 'bar' which creates bar charts.
3fill in blank
hard

Fix the error in the code to correctly label the x-axis.

Matplotlib
plt.plot([1, 2, 3], [4, 5, 6])
plt.xlabel([1])
plt.show()
Drag options to blanks, or click blank then click option'
A'x label'
Bx label
Cx_label
Dxlabel
Attempts:
3 left
💡 Hint
Common Mistakes
Passing label without quotes causing a NameError.
Using wrong parameter names.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps words to their lengths only if length is greater than 3.

Matplotlib
{word: [1] for word in words if [2]
Drag options to blanks, or click blank then click option'
Alen(word)
Bword
Clen(word) > 3
Dword > 3
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word itself as the value instead of its length.
Using the wrong condition like word > 3 which compares strings to numbers.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase words to their counts only if count is positive.

Matplotlib
{ [1]: [2] for [3] in data.items() if [2] > 0 }
Drag options to blanks, or click blank then click option'
Aword.upper()
Bcount
Cword
Ddata
Attempts:
3 left
💡 Hint
Common Mistakes
Using data instead of iterating over data.items().
Not converting words to uppercase for keys.
Using count without defining it in the loop.