python elements:


variables:

types and operators:



casts:

Built in constants:

Indenting counts:
Program structure
IDLE:
dir()
Comments:

    in line text after # is ignored

    text within triple quotes
    """ this is a multiline
    comment
    indentation needs to conform """

STRINGS:
    sequence of characters such as s = "abcdefg"
    indexed wih [] starting at [0]
    s[-1] refers to last character in string
 VERY HANDY!

 STR Concatenation


"+" operator is Operand Aware

 immutable string:
automatic memory management
printing:
    _ = " " # string variable names _
    print ("hello" + _ + "there")
    pi = 3.14159
    print ('The answer is ' + str(pi)) # cast float to string in order to print


Conditionals
elif = else if
if a>0:
elif a<0:
else:


rint column titles
right align degree values
limit radians to 7 character


str is a class
math module
math.sqrt(x)
math.sin(x)
math.cos(x)

use math.pi for defined constant
use math.cos(radian) to compute cosine
print cosine in 3rd column

import sys
sys.path.append("/u/efeibush/spline")
import cubic.py # import your own code

Collections -> arrays in other languages

List [] # ordered sequence of stuff


tuple  () # n-tuple, immutable

Declare a List

List methods
ragne() function returns a list

range(stop)
range(start, stop)
range(start,stop,incr)

returns list of integres up to but not including stop

built in function
dir(__builtins__)

looping with range

numpy.linspace

import numpy
a = numpy.linspace(1., 2.,11)
for i in a:

look up list techniques


store a list of radians and a list of cosines
print the lists
use a range loop instead of while


import numpy  (if you get into large arrays)
ndarray class
princeton.edu/~freibush

delete keyword

del a[3]


unpack a list into variables

name = ["abe", "lincoln"]
first, last = name

command line arguments
shell scripting

much better text handling than csh and bsh and shell independent