Basic Python
Basic Python
2. Numpy
Numpy is a Python library used for working with arrays and Numpy is short for
"Numerical Python."
Multiple Lines
1. import matplotlib.pyplot as plt
2. import numpy as np
3. x1 = np.array([0, 1, 2, 3])
4. y1 = np.array([3, 8, 1, 10])
5. x2 = np.array([0, 1, 2, 3])
6. y2 = np.array([6, 2, 7, 11])
7. plt.plot(x1, y1, x2, y2)
8. plt.show()
Subplot
1. import Matplotlib.Pyplot as plt
2. import numpy as np
3. x = np.array([0, 1, 2, 3]) ##plot 1:
4. y = np.array([3, 8, 1, 10])
5. plt.subplot(1, 2, 1)
6. plt.plot(x,y)
7. plt.title(‘Plot 1’)
1. a = 200
2. b = 33
3. if b > a:
4. print("b is greater than a")
5. elif a == b:
6. print("a and b are equal")
7. else:
8. print("a is greater than b")