0
0
Data Analysis Pythondata~10 mins

Bar charts in Data Analysis Python - 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 library needed to create bar charts.

Data Analysis Python
import [1] as plt
Drag options to blanks, or click blank then click option'
Aseaborn
Bnumpy
Cpandas
Dmatplotlib.pyplot
Attempts:
3 left
💡 Hint
Common Mistakes
Importing pandas or numpy instead of matplotlib.pyplot.
Using seaborn without importing matplotlib.pyplot.
2fill in blank
medium

Complete the code to create a simple bar chart from the data.

Data Analysis Python
plt.bar([1], [5, 7, 3])
plt.show()
Drag options to blanks, or click blank then click option'
A["X", "Y", "Z"]
B[1, 2, 3]
C["A", "B", "C"]
D[10, 20, 30]
Attempts:
3 left
💡 Hint
Common Mistakes
Using numbers as x-axis labels without meaning.
Using a list of values that does not match the bar heights.
3fill in blank
hard

Fix the error in the code to correctly label the bars.

Data Analysis Python
labels = ["Red", "Blue", "Green"]
values = [10, 15, 7]
plt.bar(range(len(values)), values)
plt.xticks([1], labels)
plt.show()
Drag options to blanks, or click blank then click option'
Arange(len(values))
Bvalues
Clabels
D[0, 1, 2]
Attempts:
3 left
💡 Hint
Common Mistakes
Passing labels instead of positions to plt.xticks.
Passing values instead of positions to plt.xticks.
4fill in blank
hard

Fill both blanks to create a bar chart with custom colors and title.

Data Analysis Python
colors = [[1]]
plt.bar(["A", "B", "C"], [3, 6, 9], color=[2])
plt.title("[3]")
plt.show()
Drag options to blanks, or click blank then click option'
A["red", "green", "blue"]
B[3, 6, 9]
C["cyan", "magenta", "yellow"]
DBar Chart
Attempts:
3 left
💡 Hint
Common Mistakes
Using numbers instead of color names for colors.
Not adding a title or using a wrong type for title.
5fill in blank
hard

Fill all three blanks to create a horizontal bar chart with labels and values.

Data Analysis Python
labels = ["Apple", "Banana", "Cherry"]
values = [10, 5, 8]
plt.barh([1], [2], color="orange")
plt.xlabel("[3]")
plt.show()
Drag options to blanks, or click blank then click option'
Alabels
Bvalues
CQuantity
Dcolors
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping labels and values in the barh function.
Not labeling the x-axis properly.