#### Comments? Instructions? ... Buehler? ### Basic Functions #print "Hello World!" "1+1", 1+1 #type("Hello, World!") >>> string #variable = "Variable Size" #name = raw_input ("What...is your name? ") ##Assigns keyboard input to var # ### Math #20+32, hour-1, hour*60+minute #minute/60, 5**2, (5+9)*(15-7) #263 % 100 #int(3.99999) >>> 3 #float(minute)/ 60 >>> 0.98333 ## Converts variable to floating point #x==y, x!=y,x>y, x=y, x<=y ## Boolean Expressions # ### Logical Operators #and, or, not ##Returns # ### Function Definition #def NAME( List of Parameters) # Statements # return ## Finishes the function before the end # ### Function Call #NAME() # ### If Statements #if x < y: # print x, "is less than", y #elif x > y: # print x, "is greater than", y #else: # print x, "and", y, "are equal" # ### Modules #import math # ### def buildConnectionString(params): """Build a connection string from a dictionary of parameters. Returns string.""" return ";".join(["%s=%s" % (k, v) for k, v in params.items()]) if __name__ == "__main__": myParams = {"server":"mpilgrim", \ "database":"master", \ "uid":"sa", \ "pwd":"secret" \ } print buildConnectionString(myParams)