Intro to
Programming
(with Python)

Fall 2016
course
navigation

Nov 10

I have very few homeworks for this week turned in ... something would be good, if only turning my simple_cards.py into something that implements a real playing card deck.
Assignments for the remainder of the semester are posted - I encourage you to plan accordingly.
For today : more examples of the sorts of things that could be like final projects.

moby dick

counting words in Moby Dick (practice with dictionaries, input/output, lists, words).
$ time ./count_words.py Counting words in 'moby_dick.txt'... done. Processed 208433 words in 22447 lines. Top 100 words are 1 14065 : the 2 6437 : of 3 6257 : and 4 4534 : a 5 4489 : to 6 4048 : in 7 2881 : that 8 2484 : his ....

"turtle" graphics

https://docs.python.org/2/library/turtle.html
import turtle for i in range(4): turtle.forward(100) turtle.right(90)
import turtle turtle.colormode(255) for i in range(100): turtle.forward(i) turtle.right(25) turtle.color(((255-i),i,255), (0,0,0))

python random art

(f(x,y), g(x,y), h(x,y)) (sin(pi * x), cos(pi x*y), sin(pi * y))

pig latin

The code we wrote in class is attached.

blender

>>> c = bpy.data.objects["Cube"] # default object >>> c.location = c.location + Vector((1.0, 0.0, 0.0)) # move it >>> c.scale >>> c.scale = Vector((2.0, 2.0, 2.0)) # change it's size
duplicating an object
To play around with this you'd need to explore the blender API and vocabulary: mesh, scene, data block, ...
See https://www.blender.org/api/blender_python_api_2_72_release/bpy.types.bpy_struct.html#bpy.types.bpy_struct
Animation is done through "keyframes" which are positions for objects which are shown in sequence.
A common use for scripts is to add user GUI elements to Blender's user interface, so much of the docs describe adding tooltips and so on, not just generating content from the command or running a python script.


Your ideas ?
http://cs.marlboro.edu/ courses/ fall2016/python/ notes/ Nov_10
last modified Thursday November 10 2016 11:12 am EST

attachments [paper clip]

     name last modified size
   piggy.py Nov 10 2016 11:11 am 1.17kB