# Visual Python Prelab Exercise September 24 2009 # # Thornton Vaseltarps first visual python graph # # Run this program on any of the computers in H204, # the KINSC computer lab more or less directly above # the introductory lab where we meet. # # Go to Start -> All Programs-> VIDLE for Vpython and open VIDLE # # Go to File -> Open in the VIDLE menu and navigate to this program # # In the VIDLE menu go to Run -> Run Module to run the program # # You will see a window with a plot in it # The window will be labelled ``Thornton Vaseltarp's first vpython graph'' # # Now read through the program and change the variable graphtitle so that # Thornton vaseltarp is replaced by your name - make sure you leave the quote marks " " # alone # # Change the value of parameter to any number between 4 and 10 # # Now run the program again and you will see a window labelled with your name, # and a slightly different graph. # # Click on this window and press Alt-PrintScreen together to perform a screengrab of the window # # Open a blank Microsoft word document and hit ctrl-V to paste your screengrab into the document # # Adjust the size of the image in Word so it fits on the page # # Print out your graph and bruing it to lab with you. from visual import * from visual.graph import * # import graphing features # set up some parameters graphtitle = "Thornton Vaseltarp's first visual python graph" parameter = 6 #set up some other parameters t_start = 0 t_end = 10*2*pi dt = 0.01 linecolor = color.black #and some other parameters #create a graph graph1 = gdisplay(x=50, y=500, width=1200, height=600, title=graphtitle, xtitle='t', ytitle='Position', foreground=color.black, background=color.white) funct1 = gcurve(color=linecolor) for n in range(int((t_end-t_start)/dt)): t = n*dt funct1.plot(pos=(t-parameter*sin(t),parameter*(1-cos(t)) )) # curve