Q. What changes will you recommend to rectify the error in given code?


(Note. All required libraries have been imported and are available)

a = range (10, 50, 12)
b = range (90, 200, 20)
matplotlib.pyplot.plot(a, b)

Answer :-

Since both the sequences being plotted must match in their shape, we can achieve this either by adding two elements to sequence a so that it has the same shape as sequence b (i.e., 6 elements) or by removing two elements from sequence b so that it matches the shape of sequence a (i.e., 4 elements).


For instance :-

import matplotlib.pyplot as plt

a = range (10, 50, 12)
b = range (90, 160, 20)

plt.plot(a, b)
plt.show()


Output :-



Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post