Thursday, 11 March 2021

Class 12 IP Practical - 07

 

#7 - Given a series nfib that contains reversed Fibonacci numbers with Fibonacci numbers as show below:

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

 Write a program to plot nfib with following specifications:                

 (a)    The line color should be magenta

 (b)   The marker edge color should be black with size 5

 (c)    Grid should be displayed


import matplotlib.pyplot as plt

import numpy as np

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

plt.plot(range(-10,10),nfib,'mo',markersize=5,linestyle='solid',markeredgecolor='k')

plt.grid(True)

plt.xlabel("X Axis")

plt.ylabel("Y Axis")

plt.title("Reversed Fibonacci Numbers with Fibonacci Series")

plt.legend()

plt.show()







No comments:

Post a comment