0
0
Data Analysis Pythondata~10 mins

Styling and themes 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 set the default style to 'ggplot' using matplotlib.

Data Analysis Python
import matplotlib.pyplot as plt
plt.style.use('[1]')
plt.plot([1, 2, 3], [4, 5, 6])
plt.show()
Drag options to blanks, or click blank then click option'
Aclassic
Bseaborn
Cggplot
Ddark_background
Attempts:
3 left
💡 Hint
Common Mistakes
Using a style name that is not installed or misspelled.
Forgetting to import matplotlib.pyplot as plt.
2fill in blank
medium

Complete the code to apply the 'seaborn-darkgrid' style to the plot.

Data Analysis Python
import matplotlib.pyplot as plt
plt.style.use('[1]')
plt.plot([10, 20, 30], [1, 4, 9])
plt.show()
Drag options to blanks, or click blank then click option'
Aseaborn-darkgrid
Bseaborn-white
Cfivethirtyeight
Dbmh
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'seaborn-dark' instead of 'seaborn-darkgrid'.
Not calling plt.show() to display the plot.
3fill in blank
hard

Fix the error in the code to set the style to 'bmh'.

Data Analysis Python
import matplotlib.pyplot as plt
plt.style.[1]('bmh')
plt.plot([1, 2, 3], [3, 2, 1])
plt.show()
Drag options to blanks, or click blank then click option'
Ause
Bset_style
Cstyle
Dapply
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-existent method like 'set_style' or 'apply'.
Calling plt.style as a function instead of using the 'use' method.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps each style name to its description length.

Data Analysis Python
styles = ['ggplot', 'bmh', 'seaborn-darkgrid']
descriptions = {style: len(style) for style in styles if style [1] '[2]'}
Drag options to blanks, or click blank then click option'
Astartswith
Bendswith
Cgg
Dgrid
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'endswith' instead of 'startswith'.
Using the wrong substring to filter styles.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps style names to their uppercase form if they contain 'dark'.

Data Analysis Python
styles = ['ggplot', 'bmh', 'seaborn-darkgrid']
result = {style: style[1]() for style in styles if '[2]' [3] style}
Drag options to blanks, or click blank then click option'
A.upper
Bdark
Cin
D.lower
Attempts:
3 left
💡 Hint
Common Mistakes
Using '.lower()' instead of '.upper()'.
Using '==' instead of 'in' to check substring presence.