Skip to content

Instantly share code, notes, and snippets.

@sushant-hiray
Created September 26, 2014 18:05
Show Gist options
  • Save sushant-hiray/814dd93ce2c56cca3ed2 to your computer and use it in GitHub Desktop.
Save sushant-hiray/814dd93ce2c56cca3ed2 to your computer and use it in GitHub Desktop.
from graphics import *
def get_y(x):
return x*x*x - 2*x +2
def main():
win = GraphWin("Graphing calulator", 300, 300)
win.yUp()
x_prev = -10
y_prev = get_y(x_prev)
pt = Point(x_prev, y_prev)
for i in range(-1000, 1000):
j = (float)i/(float)100
pt_new = Point(j, get_y(j))
line = Line(pt, pt_new)
line.draw(win)
pt = pt_new
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment