Subplot of G.P, A.P, H.P and Fibonacci series in Python

Subplot of G.P, A.P, H.P and Fibonacci series in Python

Also read, 

Python Code:
import numpy as np
from matplotlib import pyplot as plt
m1 =[]
print('enter values of GP series')
a = int(input('enter the first term'))
n = int(input('enter the number of terms'))
r = int(input('enter common ratio'))
y1 = np.linspace(1,n,n,dtype=int)
print('G.P. series is')
i = 1while(i<=n):
    cr = a*(r**(i-1))
    m1.append(cr)
    i = i +1print(m1)
m2 =[]
print('enter values of A.P. series')
a = int(input('enter first term'))
n = int(input('enter number of terms'))
d = int(input('enter the common difference'))
y2 = np.linspace(1,n,n,dtype=int)
print('A.P. series is')
i = 1while(i<=n):
    cr = a +(i-1)*d
    m2.append(cr)
    i = i+1print(m2)
m3 = []
print('enter values of H.P. series')
a = int(input('enter first term '))
n = int(input('enter number of terms'))
d = int(input('enter common difference of divident'))
y3 = np.linspace(1,n,n,dtype=int)
print('HP series is:')
i = 1while(i<=n):
    cr = a+(i-1)*d
    tr = 1/(a+ (i-1)*d)
    s = str('1')+'/'+str(cr)
    m3.append(tr)
    print(s)
    i = i+1print(m3)
m4 = []
print('enter values of fibonacci series')
fib1 = int(input('enter the first term'))
fib2 = int(input('enter the second term'))
n = int(input('enter number of terms'))
y4 = np.linspace(1,n,n,dtype=int)
print('fibonacci series is')
m4.append(fib1)
m4.append(fib2)
i = 3while(i<=n):
    fib3 = fib1 + fib2
    fib1 = fib2
    fib2 = fib3
    m4.append(fib3)
    i = i+1print(m4)
plt.figure(1)
plt.subplot(221)
plt.plot(y1,m1,'g*')
plt.ylabel('value of terms')
plt.title('G.P series')
plt.subplot(222)
plt.plot(y2,m2,'ro')
plt.xlabel('position of terms')
plt.ylabel('values of terms')
plt.title('Graph of A.P Series')
plt.subplot(223)
plt.plot(y3,m3,'bo')
plt.xlabel('position of terms')
plt.ylabel('values of terms')
plt.title('Graph of H.P Series')
plt.subplot(224)
plt.plot(y4,m4,'g*')
plt.ylabel('values of terms')
plt.title('fibonacci series')
plt.tight_layout()
plt.show()
Output:
enter values of GP series
enter the first term 1
enter the number of terms 7
enter common ratio 3
G.P. series is
[1, 3, 9, 27, 81, 243, 729]

enter values of A.P. series
enter first term 1
enter number of terms 8
enter the common difference 3
A.P. series is
[1, 4, 7, 10, 13, 16, 19, 22]

enter values of H.P. series
enter first term  2
enter number of terms 9
enter common difference of divident 4
HP series is:
1/2
1/6
1/10
1/14
1/18
1/22
1/26
1/30
1/34
[0.5, 0.16666666666666666, 0.1, 0.07142857142857142, 0.05555555555555555, 0.045454545454545456, 0.038461538461538464, 0.03333333333333333, 0.029411764705882353]
enter values of fibonacci series
enter the first term 1 
enter the second term 3 
enter number of terms 6
fibonacci series is
[1, 3, 4, 7, 11, 18]
Subplot of G.P, A.P, H.P and Fibonacci series in Python
Subplot of G.P, A.P, H.P and Fibonacci series in Python