Dear Pythoneers,
I want to draw several curves in one graph, but the amount of curves is not
a fixed number.
My homework is below:
---
import matplotlib.pyplot as plt
import math
if __name__=='__main__':
try:
n=int(input('how many curves? '))
ulist=[]
thetalist=[]
for i in range(n):
ulist.append(float(input('Enter velocity: ')))
thetalist.append(float(input('Enter angle: ')))
except ValueError:
print('invalid input')
else:
generateFr(?????)
def generateFr(u, theta):
theta=math.radians(theta)
g=9.8
tflight=2*u*math.sin(theta)/g
intervals=frange(0, tflight, 0.001)
x=[]
y=[]
for t in intervals:
x.append(u*math.cos(theta)*t)
y.append(u*math.sin(theta)*t - 0.5*g*t*t)
drawgraph(x, y)
def frange(start, final, increment):
numbers=[]
while start<final:
numbers.append(start)
start+=increment
return numbers
def drawgraph(x, y):
plt.plot(x, y)
plt.xlabel('x-coordinate')
plt.ylabel('y-coordinate')
plt.title('Projectile motion')
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor