Last login: Thu Dec 31 15:16:26 on ttys002 odd% python Python 3.5.1 |Anaconda 2.4.1 (x86_64)| (default, Dec 7 2015, 11:24:55) [GCC 4.2.1 (Apple Inc. build 5577)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> 1+1 2 >>> 1+1*10+64/3 32.33333333333333 >>> 1+1*10 11 >>> (1+1)*10 20 >>> a=10 >>> for=10 File "", line 1 for=10 ^ SyntaxError: invalid syntax >>> a 10 >>> a*5 50 >>> "alphabet" 'alphabet' >>> a="alphabet" >>> a 'alphabet' >>> a=5 >>> b=10 >>> c=a+b >>> c 15 >>> a=10 >>> a 10 >>> c 15 >>> a 10 >>> a="abc" >>> a 'abc' >>> a*5 'abcabcabcabcabc' >>> a=10 >>> a85 Traceback (most recent call last): File "", line 1, in NameError: name 'a85' is not defined >>> a*5 50 >>> a="10" >>> a*5 '1010101010' >>> >>> "abc" 'abc' >>> 'abc' 'abc' >>> """abc""" 'abc' >>> "can't" "can't" >>> 'can't' File "", line 1 'can't' ^ SyntaxError: invalid syntax >>> 'he said "hi"' 'he said "hi"' >>> 'can\'t' "can't" >>> 'this File "", line 1 'this ^ SyntaxError: EOL while scanning string literal >>> """this ... is ... a ... test ... """ 'this\nis\na\n test\n' >>> print(5) 5 >>> print("""this ... is ... a ... test""" ... ) this is a test >>> 1 1 >>> 1.0 1.0 >>> "abc" 'abc' >>> 5/2 2.5 >>> 6/2 3.0 >>> 5//2 2 >>> -5//2 -3 >>> [1,2,3] [1, 2, 3] >>> [1,2.0,"abc"] [1, 2.0, 'abc'] >>> a=[1,2,3,4,5,"abc","def"] >>> a [1, 2, 3, 4, 5, 'abc', 'def'] >>> a[0] 1 >>> a[5] 'abc' >>> a[5]*3 'abcabcabc' >>> a[5]+a[6] 'abcdef' >>> a[-1] 'def' >>> a[-2] 'abc' >>> a[1:3] [2, 3] >>> a[0:8] [1, 2, 3, 4, 5, 'abc', 'def'] >>> a[0:7] [1, 2, 3, 4, 5, 'abc', 'def'] >>> a[0:6] [1, 2, 3, 4, 5, 'abc'] >>> a[0:5] [1, 2, 3, 4, 5] >>> even=a[0:7:2] >>> odd=a[1:7:2] >>> even [1, 3, 5, 'def'] >>> odd [2, 4, 'abc'] >>> odd=a[2:-1^C KeyboardInterrupt >>> a[2:-1] [3, 4, 5, 'abc'] >>> a[:] [1, 2, 3, 4, 5, 'abc', 'def'] >>> a[2:] [3, 4, 5, 'abc', 'def'] >>> a[:2] [1, 2] >>> a[:2]+a[2:] [1, 2, 3, 4, 5, 'abc', 'def'] >>> [1,2,3]+[3,4,5] [1, 2, 3, 3, 4, 5] >>> a [1, 2, 3, 4, 5, 'abc', 'def'] >>> len(a) 7 >>> a [1, 2, 3, 4, 5, 'abc', 'def'] >>> a.append(19) >>> a [1, 2, 3, 4, 5, 'abc', 'def', 19] >>> a.remove(2) >>> a [1, 3, 4, 5, 'abc', 'def', 19] >>> a.remove('abc') >>> a [1, 3, 4, 5, 'def', 19] >>> a.remove('abc') Traceback (most recent call last): File "", line 1, in ValueError: list.remove(x): x not in list >>> a [1, 3, 4, 5, 'def', 19] >>> del a[2] >>> a [1, 3, 5, 'def', 19] >>> a [1, 3, 5, 'def', 19] >>> a=[1,2,3,4,5,2,3,1,4,5,8] >>> a [1, 2, 3, 4, 5, 2, 3, 1, 4, 5, 8] >>> a.cout(2) Traceback (most recent call last): File "", line 1, in AttributeError: 'list' object has no attribute 'cout' >>> a.count(2) 2 >>> a.sort() >>> a [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 8] >>> a=["a","c","b","gamma","alpha"] >>> a ['a', 'c', 'b', 'gamma', 'alpha'] >>> a.sort() >>> a ['a', 'alpha', 'b', 'c', 'gamma'] >>> a=["a","c","b","gamma","alpha",1,2,3] >>> a.sort() Traceback (most recent call last): File "", line 1, in TypeError: unorderable types: int() < str() >>> a=[1,2,3,4,5,2,3,1,4,5,8] >>> a [1, 2, 3, 4, 5, 2, 3, 1, 4, 5, 8] >>> a.reverse() >>> a [8, 5, 4, 1, 3, 2, 5, 4, 3, 2, 1] >>> b=sorted(a) >>> b [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 8] >>> a [8, 5, 4, 1, 3, 2, 5, 4, 3, 2, 1] >>> a="this is a big test string" >>> a 'this is a big test string' >>> a[3:10] 's is a ' >>> b [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 8] >>> b[2]=10 >>> b [1, 1, 10, 2, 3, 3, 4, 4, 5, 5, 8] >>> a 'this is a big test string' >>> a[2]="x" Traceback (most recent call last): File "", line 1, in TypeError: 'str' object does not support item assignment >>> a 'this is a big test string' >>> a.upper() 'THIS IS A BIG TEST STRING' >>> a 'this is a big test string' >>> a.count("e") 1 >>> a.count("t") 4 >>> a.replace("t","x") 'xhis is a big xesx sxring' >>> a=[1,2,3,4] >>> a [1, 2, 3, 4] >>> b=(1,2,3,4) >>> b (1, 2, 3, 4) >>> a [1, 2, 3, 4] >>> b (1, 2, 3, 4) >>> a[1]=10 >>> b[1]=10 Traceback (most recent call last): File "", line 1, in TypeError: 'tuple' object does not support item assignment >>> a={1,2,3,4,5,6,7} >>> a {1, 2, 3, 4, 5, 6, 7} >>> a[2] Traceback (most recent call last): File "", line 1, in TypeError: 'set' object does not support indexing >>> a={2,4,6,1,3,5} >>> a {1, 2, 3, 4, 5, 6} >>> 1==2 False >>> 1==1 True >>> {1,2,3}=={3,2,1} True >>> a={1,2,3} >>> b={3,4,5} >>> a {1, 2, 3} >>> b {3, 4, 5} >>> a.union(b) {1, 2, 3, 4, 5} >>> a.intersection(b) {3} >>> a={1:2,2:3,3:4,4:"alpha",5:1.12} >>> a {1: 2, 2: 3, 3: 4, 4: 'alpha', 5: 1.12} >>> a[3] 4 >>> a[0] Traceback (most recent call last): File "", line 1, in KeyError: 0 >>> a[4] 'alpha' >>> a[5] 1.12 >>> a="alpha" >>> b={a:5,2:3} >>> b {'alpha': 5, 2: 3} >>> b[5]=10 >>> b {'alpha': 5, 2: 3, 5: 10} >>> b[(1,2)]="xyz" >>> b {(1, 2): 'xyz', 'alpha': 5, 2: 3, 5: 10} >>> b[(1,2)] 'xyz' >>> a 'alpha' >>> a=[1,3,4,7,2,-10] >>> a [1, 3, 4, 7, 2, -10] >>> max(a) 7 >>> min(a) -10 >>> a="123.5" >>> print(a) 123.5 >>> a '123.5' >>> float(a) 123.5 >>> float(a)*5 617.5 >>> str(float(a)*5) '617.5' >>> list("abcdef") ['a', 'b', 'c', 'd', 'e', 'f'] >>> str(list("abcdef")) "['a', 'b', 'c', 'd', 'e', 'f']" >>> odd%