Below is the code in the Python interpretor from Rodger's class Sept 8. Note: In order to be able to read the files poe.txt and fivewords.txt, I created a data folder in C: on my Windows machine and put the files in there. On a Windows machine, when using the Python Interpretor, Eclipse looks for the file in C: Note if you were running a program that you created as a Python Module, then Eclipse would look in the same folder for a data file. Also below, I did not show all the text from poe.txt or the list of the words from poe.txt since both were a lot of output! Here is the console and output: x = 5 type(x) Out[3]: int print x 5 print 5/2 2 y = x * 5 5.0 type(y) Out[7]: float print y 275.0 y = y + 1 print y 276.0 x = "hello" type x File "", line 1 type x ^ SyntaxError: invalid syntax type(x) Out[13]: str print x hello x = x + "class" print x helloclass x = x + " class" print x helloclass class x = "Monty Python" print x[:3] Mon print x[0:3] Mon x = x * 3 print x Monty PythonMonty PythonMonty Python x = x - "Python" Traceback (most recent call last): File "C:\Users\Susan\AppData\Local\Enthought\Canopy\User\lib\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 x = x - "Python" TypeError: unsupported operand type(s) for -: 'str' and 'str' x = x[:-6] print x Monty PythonMonty PythonMonty x = "MontyPython"*3 print x MontyPythonMontyPythonMontyPython print x[:6] MontyP print 3 + 5 * 4 23 print (3 + 5) * 4 32 print "I " + "love " + "Python" I love Python print "I " + "love " + '"Python"' I love "Python" print "a" + "b" + 3 Traceback (most recent call last): File "C:\Users\Susan\AppData\Local\Enthought\Canopy\User\lib\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 print "a" + "b" + 3 TypeError: cannot concatenate 'str' and 'int' objects print "a" "b" ab print "a" "b" * 3 ababab print "a" ("b" * 3) Traceback (most recent call last): File "C:\Users\Susan\AppData\Local\Enthought\Canopy\User\lib\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 print "a" ("b" * 3) TypeError: 'str' object is not callable name = "/data/poe.txt" ff = open(name) type(name) Out[40]: str type(ff) Out[41]: file st = ff.read() type(st) Out[43]: str print st The Cask of Amontillado Edgar Allan Poe The thousand injuries of Fortunato I had borne as I best could, but when he ventured upon insult I vowed revenge. You, who so well know the nature of my soul, will not suppose, however, that I gave utterance to a threat. At length I would be avenged; [rest of poe.txt not shown] type(st) Out[45]: str type(ff) Out[46]: file words = st.split() type(words) Out[48]: list print words ['The', 'Cask', 'of', 'Amontillado', 'Edgar', 'Allan', 'Poe', 'The', 'thousand', 'injuries', 'of', 'Fortunato', 'I', 'had', 'borne', 'as', 'I', 'best', 'could,', 'but', 'when', 'he', 'ventured', 'upon', 'insult', 'I', 'vowed', 'revenge.', 'You,', 'who', 'so', 'well', 'know', 'the', 'nature', [NOT ALL LIST ELEMENTS SHOWN]'no', 'mortal', 'has', 'disturbed', 'them.', 'In', 'pace', 'requiescat!'] print "number of words in the file is ", len(words) number of words in the file is 2324 name = "/data/fivewords.txt" ff = open(name) st = ff.read() print st file with five words here words = st.split() print "Number of words in ", name, " is ", len(words) Number of words in /data/fivewords.txt is 5 print words ['file', 'with', 'five', 'words', 'here']