The Python installation includes an interactive interpreter that you can use to execute code as you type it. This is a great tool to use to try small samples and see the result immediately without having to manage output or print statements.
If you have not done it yet, download the lab files at the following URL: https://thenewcircle.com/static/student-files/python_fundamentals_labs.zip
(Linux / Mac) Open a terminal and type
(Windows) Open the Python IDLE IDE from the Start menu.
help(str)This is a simple way to get documentation for a builtin or standard library function. You can also use the online HTML documentation.
>>> help(str) Help on class str in module __builtin__: class str(basestring) | str(object) -> string | | Return a nice string representation of the object. | If the argument is a string, the return value is the same object. | | Method resolution order: | str | basestring | object | | Methods defined here: | | __add__(...) | x.__add__(y) <==> x+y | ...
__add__()method gets executed?
>>> 'hello world' 'hello world' >>> _ + '!' 'hello world!' >>> hw = _ >>> hw 'hello world!'
In the interactive interpreter, you can use the special variable "_" to refer to the result of the last statement. Handy in this mode, but meaningless in scripts.
Throughout the rest of this courseware, the ">>>" in a listing indicates that the code is being executed in the interactive interpreter.