Complete the code to invert the y-axis in the plot.
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6]) plt.[1]() plt.show()
The method invert_yaxis() flips the y-axis direction in the plot.
Complete the code to invert the x-axis using the Axes object.
import matplotlib.pyplot as plt fig, ax = plt.subplots() ax.plot([1, 2, 3], [4, 5, 6]) ax.[1]() plt.show()
The invert_xaxis() method on the Axes object flips the x-axis direction.
Fix the error in the code to invert the y-axis correctly.
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6]) plt.[1]() plt.show()
The correct method to invert the y-axis is invert_yaxis(). Other options are either misspelled or incorrect.
Fill both blanks to create a dictionary comprehension that maps numbers to their squares only if the number is less than 4.
squares = {x: x[1]2 for x in range(1, 6) if x [2] 4}The operator ** is used for exponentiation (power), and < is the less than comparison operator.
Fill all three blanks to create a dictionary comprehension that maps uppercase letters to their ASCII values only if the ASCII value is greater than 65.
ascii_map = [1]: ord([3]) for [1] in 'ABCDEF' if ord([3]) [2] 65}
We use letter as the variable name, > as the comparison operator, and letter inside ord() to get ASCII values.