Write a program to plot a graph of function f(x) = x
n + xn-1
. Your program should take a maximum
absolute value of x as well as a positive integer n as input. You will plot a graph for the range [0, x]. You
should label the y-axis according to the maximum value of x.
import matplotlib.pyplot as plt
x = 4
list1 = [i for i in range(0,x)]
n = 4
list2 = []
for i in list1:
list2.append( n + i * n -1)
plt.plot(list1,list2)
plt.title('title name')
plt.xlabel('X')
plt.ylabel('n + i * n -1')
Comments
Leave a comment