Challenge - 5 Problems
Color Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What color will this plot line be?
Look at the code below. What color will the line be when plotted using matplotlib?
Matplotlib
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6], color='navy') plt.show()
Attempts:
2 left
💡 Hint
Named colors like 'navy' correspond to specific hex codes representing colors.
✗ Incorrect
The named color 'navy' corresponds to a dark blue shade in matplotlib.
❓ data_output
intermediate2:00remaining
What hex code does this named color represent?
Given the named color 'tomato' in matplotlib, what is its hex code?
Matplotlib
import matplotlib.colors as mcolors hex_code = mcolors.CSS4_COLORS['tomato'] print(hex_code)
Attempts:
2 left
💡 Hint
Check the CSS4_COLORS dictionary for the exact hex code.
✗ Incorrect
The named color 'tomato' corresponds to the hex code '#ff6347' in matplotlib's CSS4_COLORS.
❓ visualization
advanced2:00remaining
Identify the color shown by this hex code
This code plots a line with color '#8A2BE2'. What named color does this hex code represent?
Matplotlib
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [3, 2, 1], color='#8A2BE2') plt.show()
Attempts:
2 left
💡 Hint
Look up the hex code '#8A2BE2' in matplotlib's named colors.
✗ Incorrect
The hex code '#8A2BE2' corresponds to the named color 'BlueViolet' in matplotlib.
🧠 Conceptual
advanced2:00remaining
Why use named colors instead of hex codes?
Which of the following is the best reason to use named colors like 'crimson' instead of hex codes like '#DC143C' in matplotlib?
Attempts:
2 left
💡 Hint
Think about readability and ease of use.
✗ Incorrect
Named colors are easier for humans to remember and understand compared to hex codes, which are less intuitive.
🔧 Debug
expert2:00remaining
What error does this code raise?
What error will this matplotlib code raise?
Matplotlib
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6], color='#GGHHII') plt.show()
Attempts:
2 left
💡 Hint
Hex codes must contain valid hexadecimal digits (0-9, A-F).
✗ Incorrect
The hex code '#GGHHII' contains invalid characters, causing matplotlib to raise a ValueError for invalid RGBA argument.