I am trying to graph a fuction using matplotlib in Jupyter notebooks in python.
ID: 3880017 • Letter: I
Question
I am trying to graph a fuction using matplotlib in Jupyter notebooks in python. My code is below. I don't understand why I am getting the error message.
import math def quadratic_formula (a, b, c): root! root2 return (-b + (-b - rooti, math. sqrt(b*b math. sqrt(b*b root 4*a*c))/(2*a) 4*a*c))/(2*a) - - time-1, time-2 quadratic-formula(a,b,c) = total time max(time 1 ,time 2) print('The ball will hit the ground in', total_time, seconds. ') import matplotlib.pyplot as plt for x in range(-4, 4, 1): y-16(x* *2)+20 (x)+5e d.append(x) e.append (y) fig- plt.figure() axes-fig.add_subplot (111) axes plot(d,e) plt.show( Traceback (most recent call last) TypeError ipython-input-2-f7a6de20daabs in () 7 for x in range(-4, 4, 1): > 8 y= -16(x"*2)+20(x)+50 9 d.append(x) 10 eappend(y) TypeError: 'int' object is not callableExplanation / Answer
You are getting this error because you are not writing expression properly
Compiler or Interpreter doesn't understant like human so we need to specify each symbol at each place properly
So in you expression:
y=-16(x**2)+20(x)+50 => you are trying to multiply two values without multiplicaton operator
-16 and x**2, 20 and x to multiply these you need to put * operator between them
Pleae find correct expression below
y=-16*(x**2)+20*(x)+50
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.