Derivative using NumPy
Unit 3 Sections 14 and 15 lesson
import numpy as np
new_matrix = np.array([[1, 2, 3],[4, 5, 6],[7, 8, 9]])
print (new_matrix)
import numpy as np
# defining polynomial function
var = np.poly1d([2, 0, 1])
print("Polynomial function, f(x):\n", var)
# calculating the derivative
derivative = var.deriv()
print("Derivative, f(x)'=", derivative)
# calculates the derivative of after
# given value of x
print("When x=5 f(x)'=", derivative(5))
import random
def Dice(n):
sum = 0
while n > 0:
sum = sum + random.randint(1, 6)
n -=1
return sum
Dice(5) # Will output a range of 5 to 30