Introductory Programming Fall 2004 For next time: 1) Read Chapter 2 of How to Think... 2) follow the instructions in Chapter 2 of Olinux But don't spend more than two hours, total. (pass/NR for sophomores by October 8) Quick Linux review ------------------ User and superuser Accounts and environments The prompt (typeahead) Files and directories The "working" directory pwd, ls and cd Commands, arguments and options Maintenance ----------- 1) Can we boot? 2) Do we have a user account? 3) Have we updated? The Python Interpreter ---------------------- Log is as a user and open a terminal. Type "python" $ python Python 2.3.3 (#1, May 7 2004, 10:31:40) [GCC 3.3.3 20040412 (Red Hat Linux 3.3.3-7)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> The chevron >>> is the Python prompt. Try this: >>> 3+1 4 What you are running is the Python (interactive) interpreter. If you type a statement, Python executes it. If you type an expression, Python evaluates it and prints the result. 3+1 is a mathematical expression, and the result is 4 Try this: >>> from math import * >>> cos(pi) -1.0 Again, Python evaluates the expression and prints the result. Try this: >>> print 'hello' hello This is a print statement; Python executes it, which has the effect of displaying the word hello. Now try this: >>> print 'hello I left off the close quotation mark. What happens? Congratulations! You just made your first syntax error. (EOL = end of line character) Exiting the interpreter ----------------------- Press Control-c. Type "quit" Type "exit" Press Control-d. Topics from Chapter 1 --------------------- Compilers and interpreters. Errors and debugging. Preview of Chapter 2 -------------------- Evaluating expressions. Executing statements. Get started on Olinux Chapter 2.