Dear Pythoneers, sorry for bothering. 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(?????) # here I want to draw several curves with ulist[0], thetalist[0], ulist[1], thetalist[1]... ... ulist[n-1], thetalist[n-1]* 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') ------------------------------------------------------------------------------ Thank you very much. I hope I describe my question clearly. Tom _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor