3+3 Out[2]: 6 type(3+3) Out[3]: int x = 3+3 x Out[5]: 6 x+5 Out[6]: 11 x*5 Out[7]: 30 x**2 Out[8]: 36 x Out[9]: 6 x/4 Out[10]: 1 x Out[11]: 6 s = "hello" type(s) Out[13]: str s + " world" Out[14]: 'hello world' s Out[15]: 'hello' s * 5 Out[16]: 'hellohellohellohellohello' s + 5 Traceback (most recent call last): File "/Users/ola/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2883, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in s + 5 TypeError: cannot concatenate 'str' and 'int' objects 5 + str Traceback (most recent call last): File "/Users/ola/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2883, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in 5 + str TypeError: unsupported operand type(s) for +: 'int' and 'type' 3.1 * 5 Out[19]: 15.5 type(3.1) Out[20]: float 6.0/4 Out[21]: 1.5 6/4 Out[22]: 1 "hello".count('l') Out[23]: 2 f = open("/data/kjv10.txt") type(f) Out[25]: file st = f.read() type(st) Out[27]: str len(st) Out[28]: 4345018 for ch in "abcdefghijklmnopqrstuvwxyz": print ch,st.count(ch) a 257427 b 44053 c 53069 d 149107 e 408889 f 81028 g 48940 h 279260 i 180213 j 2471 k 21660 l 120634 m 76736 n 222716 o 233757 p 41206 q 959 r 162260 s 184899 t 309412 u 82949 v 30226 w 62912 x 1555 y 57929 z 2073 3+3 Out[30]: 6 type(3+3) Out[31]: int x = 3 type(x) Out[33]: int x + 9 Out[34]: 12 x * 22 Out[35]: 66 x ** 5 Out[36]: 243 z = "hello" type(z) Out[38]: str z = 'hello' type(z) Out[40]: str z = "hello' File "", line 1 z = "hello' ^ SyntaxError: EOL while scanning string literal z = "hello" z + " world" Out[43]: 'hello world' z Out[44]: 'hello' z * 4 Out[45]: 'hellohellohellohello' z Out[46]: 'hello'z Out[48]: 'hello' z * 5 Out[49]: 'hellohellohellohellohello' z + 5 Traceback (most recent call last): File "/Users/ola/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2883, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in z + 5 TypeError: cannot concatenate 'str' and 'int' objects 3 + 5 Out[51]: 8 5 + 3 Out[52]: 8 5 + z Traceback (most recent call last): File "/Users/ola/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2883, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in 5 + z TypeError: unsupported operand type(s) for +: 'int' and 'str' 100/2 Out[54]: 50 101/2 Out[55]: 50 101.0/2 Out[56]: 50.5 type(1.0) Out[57]: float 6/4 Out[58]: 1 6/4.0 Out[59]: 1.5 f = open("/data/kjv10.txt") type(f) Out[61]: file s = f.read() type(s) Out[63]: str len(s) Out[64]: 4345018 x = s.split() type(x) Out[66]: list x[-10:] Out[67]: ['of', 'our', 'Lord', 'Jesus', 'Christ', 'be', 'with', 'you', 'all.', 'Amen.'] s[-10:] Out[68]: 'll. Amen.\n' 7/2 Out[69]: 3