# QuadraticPlot.py # Neal Nelson 2008.11.17 import string from graphics import * def main(): # Introduction print "Plot points for quadratic y = a * x*x + b*x + c" a,b,c = input ("Enter parameters a,b,c; e.g. 2.0, -5.0, 2.0: ") # Display a scatter plot (xmin,xmax) = (-10,10) (ymin,ymax) = (-100,100) # Create a graphics window with (xmin,ymin) in lower left #win = GraphWin("Sample Scatter Plot", 320, 240) # small drawing window win = GraphWin("Sample Line Plot", 640, 480) # bigger drawing window win.setBackground("white") win.setCoords(xmin, ymin, xmax, ymax) # Draw x-axis and y-axis Line(Point(xmin,0), Point(xmax,0)).draw(win) # x-axis Line(Point(0,ymin), Point(0,ymax)).draw(win) # y-axis # Draw the (x,y) points for i in range(xmin,xmax+1): x = float(i) y = a*x*x + b*x + c print x,y # for debugging Point(x,y).draw(win) # Hold window open #raw_input("Press to quit.") #win.close() # A better click-to-close technique text = Text(Point(xmax/2, ymax-5), 'Click to close') text.draw(win) win.getMouse() win.close() main()