1. String "hello"+"world" hellowworld "hellow"*3 "hellohellohello" "hello"[-1] "o" from end "hello"[1:4] ell" len("hello") 5 2. List a= [99, "Bottles of beers", ["on", "the", "wall"]] same operator as strings a[0]=98] a[1:2] = ["bottles","of","beer"] -> [98, "bottles", "of", "beer", ["on", "the","wall"]] del a[-1] -> [98, "bottles", "of", "beer"] a=range[5] [0,1,2,3,4] a.apend(5) [0,1,2,3,4,5] a.pop() [0,1,2,3,4] a.reverse() [4,3,2,1,0] a.sort() [0,1,2,3,4] 3 hash table d= {"duck": "eend", "water": "water"} d["duck"] ->"eend" d["duck"]="duik" -> {"duck":"duik","back":"rug" d.keys() ["duck", "back"] d.values() d.items() d.has_key("duck") ->1 4. assignment a=[1,2,3]; b=a a.append(4) print b [1,2,3,4] 5. control structure if cond: statements elif cond: statements else: statements while cond: statements for var in sequence: statements for i in rage 5 print i indentation 6. functions def gcd (a,b): "greatest common divisor" while a!=0: a, b=b%a, a return b if __name__=="__main__": print gcd(4,10) 7. input and exceptions a=raw_input("how old are you?") try: a=int(a) print "you are"+a except ValueError: print "not a number"