Intro to
Programming
with Python

Fall 2010
course
navigation

sep 23

1. From homework : formatting multiple values; formatting strings.
# A table of integers and square roots. from math import sqrt print " %8s %8s" % ('n', 'sqrt(n)') print " %8s %8s" % ('-'*8, '-'*8) for n in range(1, 11): print " %8i %8.4f" % (n, sqrt(n))
which does this : $ python sqrts.py n sqrt(n) -------- -------- 1 1.0000 2 1.4142 3 1.7321 4 2.0000 5 2.2361 6 2.4495 7 2.6458 8 2.8284 9 3.0000 10 3.1623
2. Also from homework : cipher wrap, i.e. 'y' + 10 using mod arithmetic.

New homework for chapter 5 (object oriented graphics) is posted.
Now: practice with the graphics package described last time.
Getting input from the user: convert_gui.py
Drawing a bar plot : futval_graph_1.py
Group exercise in class : write a program that plots of graph of y = sin(x) .
One last "slightly over the top" example : string_art.py
http://cs.marlboro.edu/ courses/ fall2010/python/ notes/ sep_23
last modified Thursday September 23 2010 9:51 am EDT

attachments [paper clip]

     name last modified size
   convert_gui.py Sep 22 2010 11:50 pm 995B    futval_graph_1.py Sep 22 2010 11:45 pm 1.38kB [IMG]string_art.png Sep 22 2010 11:45 pm 236kB    string_art.py Sep 23 2010 9:51 am 3.07kB