Python Programming Lecture 1, Fall 2009

http://grace.evergreen.edu/mon/asn-python.html

What is Computer Science? - Ch 1.3

  1. Dijkstra - Computers are to Computer Science what telescopes are to astronomy.

  2. What can be computed and how
  3. Techniques - design, analysis, experimentation
  4. Core topics - Algorithms and Data Structures
  5. Applications - communications, control systems, hardware design systems, networking, human-computer interaction, artificial intelligence, scientific modeling, databases, web and multi-media design, management information systems. Software engineering and security.

What is a computer? - Ch 1.1, 1.2

  1. Hardware and software
  2. Calculators
  3. Hard-wired machines.
  4. Jacquard loom (1801)
  5. Charles Babbage and Ada Lovelace (mid 1800s)
  6. Alan Turing, Alfonso Church, and other mathematicians in the 1930s.
  7. John Von Neumann (1940s) and the stored program machine.
  8. The universal machine - "a machine that stores and manipulates information under the control of a changeable program".

Hardware Basics - Ch 1.4

  1. basic components - CPU, Input & Output devices, memory, disks. Connected with buses (see Fig 1.1 p5).

Programming Languages - Ch 1.5

  1. Machine Language
    1. Read and write memory and I/O
    2. Arithmetic (calculator stuff)
    3. Comparisons and decisions (including loops)
  2. High-level programming language
  3. Code - a program. Coding.
  4. Compilation from programming language Code to machine code (Fig 1.2)
  5. Interpreting a programming language code, say in Python or Java (Fig 1.3)
  6. Syntax (form) and Semantics (meaning).

First Python programs - Ch 1.6

  1. hello.py - always save programs with .py extension in raw text mode.
  2. Idle IDE with editor and interpreter window.
  3. Interpreter window always has >>> prompt.
  4. Interpreter remembers definitions while it is running.
  5. Interpreter does not save programs when you exit.
  6. Idle Run button to send program from editor to interpreter

  7. Comments with #
  8. hello.py - Put comments at the top: filename, your name and date, description, collaborators
  9. If you change program in Idle, you must send it again to the interpreter

  10. hellomain.py - hello() again with hello() at the end - function definition vs function invocation
  11. The convention of main(). Sample program with main() and hello()

  12. Python is case sensitive
  13. Indentation is significant in Python.
  14. Description should tell what the program does and how to run it if not obvious.

Sample program with input as well as output

  1. greet.py - a program to input your name display a greeting.
  2. greet-raw.py input (p15) vs raw_input (p79)
  3. Python script vs Python function vs Python program. Usually we say that the script has one program that it runs with main() as the starting place. The program is coded as a collection of many small functions called by main() and each other.