Thursday 11 March 2021

Class 12 IP Practical - 06

 

#6 - First 10 terms of Fibonacci series are stored in a list namely fib:          

 

fib = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]

 

Write a program to plot Fibonacci terms and their square-roots with two separate lines on the same plot.

(a)    Series should be plotted as a cyan line with ‘o’ markers having size as 5 and edge-color as red.

(b)   The square-root series should be plotted as a black line with ‘+’ markers having size as 7 and edge-color as red.

 

 

import matplotlib.pyplot as plt

import numpy as np

fib=[0,1,1,2,3,5,8,13,21,34]

sqfib=np.sqrt(fib)

plt.plot(range(1,11),fib,'co',markersize=5,linestyle='solid',markeredgecolor='r',label="fib")

plt.plot(range(1,11),sqfib,'k+',markersize=7,linestyle='solid',markeredgecolor='r',label="sqfib")

plt.xlabel("X Axis")

plt.ylabel("Y Axis")

plt.title("Fibonacci Series")

plt.legend()

plt.show()

 











No comments:

Post a Comment