Python Programming Lecture 1, Fall 2009
http://grace.evergreen.edu/mon/asn-python.html
What is Computer Science? - Ch 1.3
- Dijkstra - Computers are to Computer Science what telescopes are to astronomy.
- What can be computed and how
- Techniques - design, analysis, experimentation
- Core topics - Algorithms and Data Structures
- 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
- Hardware and software
- Calculators
- Hard-wired machines.
- Jacquard loom (1801)
- Charles Babbage and Ada Lovelace (mid 1800s)
- Alan Turing, Alfonso Church, and other mathematicians in the 1930s.
- John Von Neumann (1940s) and the stored program machine.
- The universal machine - "a machine that stores and manipulates information under the control of a changeable program".
Hardware Basics - Ch 1.4
- basic components - CPU, Input & Output devices, memory, disks. Connected
with buses (see Fig 1.1 p5).
Programming Languages - Ch 1.5
- Machine Language
- Read and write memory and I/O
- Arithmetic (calculator stuff)
- Comparisons and decisions (including loops)
- High-level programming language
- Code - a program. Coding.
- Compilation from programming language Code to machine code (Fig 1.2)
- Interpreting a programming language code, say in Python or Java (Fig 1.3)
- Syntax (form) and Semantics (meaning).
First Python programs - Ch 1.6
- hello.py - always save programs with .py extension in raw text mode.
- Idle IDE with editor and interpreter window.
- Interpreter window always has >>> prompt.
- Interpreter remembers definitions while it is running.
- Interpreter does not save programs when you exit.
- Idle Run button to send program from editor to interpreter
- Comments with #
- hello.py - Put comments at the top: filename, your name and date,
description, collaborators
- If you change program in Idle, you must send it again to the interpreter
- hellomain.py - hello() again with hello() at the end - function
definition vs function invocation
- The convention of main(). Sample program with main() and hello()
- Python is case sensitive
- Indentation is significant in Python.
- Description should tell what the program does and how to run it if not obvious.
Sample program with input as well as output
- greet.py - a program to input your name display a greeting.
- greet-raw.py input (p15) vs raw_input (p79)
- 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.