Python graphics for Halverson’s STEM and Physics classes.



Here is a simple Python Turtle Graphics that works on the students’ mac. Copy and paste this code in a file named “turtle1.py” and run it.

import turtle
turtle.showturtle()
for n in range(0,36):
print"n=",n
turtle.forward(100)
turtle.left(170)
turtle.exitonclick()

Run command: python turtle1.py
Documentation for turtle graphics is here: https://docs.python.org/2/library/turtle.html
.
Additional turtle commands to play with:
turtle.hideturtle()
turtle.speed(9) # The number is 0 through 9. 0 means max speed, no animation.
.
=========================================================
.
Here is an easy-to-use graphics Library from Professor Zell can be downloaded by clicking here: http://mcsp.wartburg.edu/zelle/python/graphics.py
Here is an example program that uses it. Copy and paste this code into a file named “graphics1.py” and run it.


from graphics import *
def main():
win = GraphWin("My Circle", 100, 100)
c = Circle(Point(50,50), 10)
c.draw(win)
win.getMouse() # pause for click in window
win.close()
main()

Documentation for this graphics library is here: http://mcsp.wartburg.edu/zelle/python/