Hi! I need code a list "d" to plot the s x t graph. The list "d" must have six itens too but if user input a value greater "a" in the list this value must be 0 in according to the equation "d=x*0". This code is a simplified example. Can someone help me?
Note
When I run the code it displays the following error message:
AttributeError: 'int' object has no attribute 'append'
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import matplotlib.pyplot a = int ( input ( "a=" ) b = int ( input ( "b=" ) c = [ 0 , 1 , 2 , 3 , 4 , 5 ] d = [] x = 0 while (x< = a): d = b * (a - x) x = x + 50 else : d = x * 0 d.append(x) matplotlib.pyplot.title( "Average Speed" ) matplotlib.pyplot.plot(c,d) matplotlib.pyplot.xlabel( "t [s]" ) matplotlib.pyplot.ylabel( "s [mi]" ) matplotlib.pyplot.show() |
When I run the code it displays the following error message:
AttributeError: 'int' object has no attribute 'append'