#!/usr/bin/env python # coding: utf-8 # # Turtle program & event handling # - there are many modules in Python that provide various useful and powerful features # - TKinter, turtle, email, url, http, etc. # - running turtle program multiple times from jupyter notebook crashes jupyter server... so run scripts by themselves in turtle folder # ## 1st turtle program # In[2]: import turtle # In[3]: help(turtle) # In[1]: import turtle # Allows us to use turtles wn = turtle.Screen() # Creates a playground for turtles alex = turtle.Turtle() # Create a turtle, assign to alex alex.forward(50) # Tell alex to move forward by 50 units alex.left(90) # Tell alex to turn by 90 degrees alex.forward(30) # Complete the second side of a rectangle wn.mainloop() # Wait for user to close window # ### add some colors # In[2]: import turtle wn = turtle.Screen() wn.bgcolor("lightgreen") # Set the window background color wn.title("Hello, Tess!") # Set the window title tess = turtle.Turtle() tess.color("blue") # Tell tess to change her color tess.pensize(3) # Tell tess to set her pen width tess.forward(50) tess.left(120) tess.forward(50) wn.mainloop() # In[ ]: