odd% python Python 2.7.5 (default, Aug 25 2013, 00:04:04) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> 1+1 2 >>> 3/2 1 >>> 3.0/2.0 1.5 >>> 3/2.0 1.5 >>> 3/2+1.0 2.0 >>> sin(1.0) Traceback (most recent call last): File "", line 1, in NameError: name 'sin' is not defined >>> from math import * >>> sin(1.0) 0.8414709848078965 >>> sqrt(-1) Traceback (most recent call last): File "", line 1, in ValueError: math domain error >>> from cmath import * >>> sqrt(-1) 1j >>> a=5 >>> a 5 >>> 5=y*3+1 File "", line 1 SyntaxError: can't assign to literal >>> x=5 >>> x*10 50 >>> x=3 >>> x*10 30 >>> y=x*5+2 >>> y 17 >>> x=7 >>> y 17 >>> abcd=10 >>> abcd 10 >>> a*b*c*d Traceback (most recent call last): File "", line 1, in NameError: name 'b' is not defined >>> a=1 >>> b=2.0 >>> a 1 >>> b 2.0 >>> 1==1 True >>> 1==2 False >>> a=1 >>> b=1.0 >>> a==b True >>> "alphabet" 'alphabet' >>> 'alphabet' 'alphabet' >>> "you can't do that" "you can't do that" >>> 'you can't do that' File "", line 1 'you can't do that' ^ SyntaxError: invalid syntax >>> """this is a string""" 'this is a string' >>> """this is a string ... it has more than ... one line""" 'this is a string\nit has more than\none line' >>> print """this is a string ... that spans several ... lines""" this is a string that spans several lines >>> a="this is a test" >>> a 'this is a test' >>> b=" more string" >>> a 'this is a test' >>> b ' more string' >>> a+b 'this is a test more string' >>> b*3 ' more string more string more string' >>> a="10" >>> a*3 '101010' >>> int(a) 10 >>> a '10' >>> int(a)*3 30 >>> string(255) Traceback (most recent call last): File "", line 1, in NameError: name 'string' is not defined >>> str(255) '255' >>> float(a) 10.0 >>> a '10' >>> [1,23,5,7] [1, 23, 5, 7] >>> a=[1,23,5,7] >>> a [1, 23, 5, 7] >>> a*2 [1, 23, 5, 7, 1, 23, 5, 7] >>> a[0] 1 >>> a[1] 23 >>> a[2] 5 >>> a=[1,2,"alpha",2.5] >>> a [1, 2, 'alpha', 2.5] >>> a=[1,2,[1,2,3],7] >>> a [1, 2, [1, 2, 3], 7] >>> a[0] 1 >>> a[2] [1, 2, 3] >>> a[2][1] 2 >>> a[1,2,3,5,6,8,9,100] Traceback (most recent call last): File "", line 1, in TypeError: list indices must be integers, not tuple >>> a=[1,2,3,5,6,8,9,100] >>> a [1, 2, 3, 5, 6, 8, 9, 100] >>> a[0:3] [1, 2, 3] >>> a[0:3]+a[3:5] [1, 2, 3, 5, 6] >>> a[-1] 100 >>> a[-2] 9 >>> a[:3] [1, 2, 3] >>> a[5:] [8, 9, 100] >>> a[-3:] [8, 9, 100] >>> a[:] [1, 2, 3, 5, 6, 8, 9, 100] >>> a [1, 2, 3, 5, 6, 8, 9, 100] >>> a[1]=55 >>> a [1, 55, 3, 5, 6, 8, 9, 100] >>> b=a >>> b [1, 55, 3, 5, 6, 8, 9, 100] >>> a[1]=7 >>> a [1, 7, 3, 5, 6, 8, 9, 100] >>> b [1, 7, 3, 5, 6, 8, 9, 100] >>> c=7 >>> d=8 >>> c=5 >>> d 8 >>> c=7 >>> d=c >>> =5 File "", line 1 =5 ^ SyntaxError: invalid syntax >>> c=5 >>> d 7 >>> a [1, 7, 3, 5, 6, 8, 9, 100] >>> b [1, 7, 3, 5, 6, 8, 9, 100] >>> b=a[:] >>> b [1, 7, 3, 5, 6, 8, 9, 100] >>> a[1]=10 >>> a [1, 10, 3, 5, 6, 8, 9, 100] >>> b [1, 7, 3, 5, 6, 8, 9, 100] >>> a=0 >>> b=0 >>> a 0 >>> b 0 >>> a="this is a test" >>> a[0] 't' >>> a[3:7] 's is' >>> a[0]="x" Traceback (most recent call last): File "", line 1, in TypeError: 'str' object does not support item assignment >>> a 'this is a test' >>> a="x"+a[1:] >>> a 'xhis is a test' >>> a=(1,2,3,6,8,9) >>> a (1, 2, 3, 6, 8, 9) >>> a[0]=5 Traceback (most recent call last): File "", line 1, in TypeError: 'tuple' object does not support item assignment >>> set((1,2,3,4,5)) set([1, 2, 3, 4, 5]) >>> set((1,2,2,5,3,4,5)) set([1, 2, 3, 4, 5]) >>> set((5,2,3,1)) set([1, 2, 3, 5]) >>> a={1:2,2:3,3:4,4:5} >>> a {1: 2, 2: 3, 3: 4, 4: 5} >>> a[1] 2 >>> a[3] 4 >>> a[8] Traceback (most recent call last): File "", line 1, in KeyError: 8 >>> a={"a":5,"b":7,3:10,"c":"alpha"} >>> >>> a {'a': 5, 3: 10, 'c': 'alpha', 'b': 7} >>> a["a"] 5 >>> a[3] 10 >>> a["c"] 'alpha' >>> a["xxx"] Traceback (most recent call last): File "", line 1, in KeyError: 'xxx' >>> a {'a': 5, 3: 10, 'c': 'alpha', 'b': 7} >>> a[22]="abcd" >>> a {'a': 5, 3: 10, 'c': 'alpha', 'b': 7, 22: 'abcd'} >>> a[22]=15 >>> a {'a': 5, 3: 10, 'c': 'alpha', 'b': 7, 22: 15} >>> ^D odd%