0
0
Matplotlibdata~10 mins

Error bars on bar charts in Matplotlib - Interactive Code Practice

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

Complete the code to import the matplotlib.pyplot module as plt.

Matplotlib
import [1] as plt
Drag options to blanks, or click blank then click option'
Anumpy
Bpandas
Cmatplotlib.pyplot
Dseaborn
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the wrong module like numpy or pandas.
Forgetting to use 'as plt' alias.
2fill in blank
medium

Complete the code to create a bar chart with error bars using plt.bar.

Matplotlib
plt.bar(x, height, yerr=[1])
Drag options to blanks, or click blank then click option'
Ax
Berrors
Cheight
Dwidth
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the wrong variable like x or height to yerr.
Not passing any error values.
3fill in blank
hard

Fix the error in the code to correctly display error bars on the bar chart.

Matplotlib
plt.bar(x, height, yerr=[1], capsize=5)
plt.show()
Drag options to blanks, or click blank then click option'
Aerror
Berr
Cerror_bars
Derrors
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name that does not exist.
Typos in the error variable name.
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)
Blen(word) > 3
Cword
Dword > 3
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word itself instead of its length as the value.
Incorrect condition syntax.
5fill in blank
hard

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

Matplotlib
{ [1]: [2] for [3], count in data.items() if count > 0 }
Drag options to blanks, or click blank then click option'
Aword.upper()
Bcount
Cword
Dcount.upper()
Attempts:
3 left
💡 Hint
Common Mistakes
Using count.upper() which is invalid since count is a number.
Swapping keys and values.