CBSE Class 12 Informatics Practices Question 123 of 147

Plotting with Pyplot — Question 6

Back to all questions
6
Question

Question 4

plt.plot(A, B) produces (A and B are the sequences same as created in question 1) chart as :

plt.plot(A, B) produces (A and B are the sequences same as created in question 3) chart as : Plotting with Pyplot, Informatics Practices Computer Science Sumita Arora Solutions CBSE Class 12

Write code to produce charts as shown below:

plt.plot(A, B) produces (A and B are the sequences same as created in question 3) chart as : Plotting with Pyplot, Informatics Practices Computer Science Sumita Arora Solutions CBSE Class 12
Answer
import numpy as np
import matplotlib.pyplot as plt

A = np.arange(2, 20, 2)
B = np.log(A)
C = np.log(A) * 1.2 
plt.plot(A, B)
plt.plot(A, C)
plt.show()
Output
plt.plot(A, B) produces (A and B are the sequences same as created in question 1) chart as : Plotting with Pyplot, Informatics Practices Computer Science Sumita Arora Solutions CBSE Class 12
import numpy as np
import matplotlib.pyplot as plt

A = np.arange(2, 20, 2)
B = np.log(A)
C = np.log(A) * (-1.2) 
plt.plot(A, B)
plt.plot(A, C)
plt.show()
Output
plt.plot(A, B) produces (A and B are the sequences same as created in question 1) chart as : Plotting with Pyplot, Informatics Practices Computer Science Sumita Arora Solutions CBSE Class 12