Lecture notes for the Introduction to Computer Science I by James Tam Return to the course web page

Example Programs: Programming Introduction

Description

Program name

The first example program that can be translated and executed.

small.py

Displaying output: showing the contents of a single variable or constant at a times

output1.py

Display output: mixed string and variable/constant output

output2.py

Getting numeric input via 'input'

input1.py

Getting character/string input via 'raw_input'

input2.py

Converting between types: real to integer

convert1.py

Converting between types: string to numeric

convert2.py

A sample program with a syntax error

syntax.py

A sample program that can produce a runtime error (division by zero)

runtime.py

A sample program with a logic error

logic.py

Formatting output: using triple quotes

formatting1.py

Formatting output: using escape codes

formatting2.py