Comp 112

Lecture 1

Course Introduction


About the Course

Course Topic

Introduction to imperative programming, using the programming language Python.

Course Objectives

Course Audience

Is this course for you?

Course Components

weekly (Tuesdays, 8:50AM, Exley 121)
weekly (time/place varies by section)
free online book: Think Python (2nd ed.). Readings assigned weekly.
weekly (released to Moodle shortly after each lecture, due by beginning of following lecture)
two midterms (on October 26 and December 5)
Programming Project
in lieu of final exam at end of semester (details to follow)

Course Resources

instructor and C.A.s
Drop-In Help Clinic
run by C.A.s on Sun., Mon. and Thurs. evenings 7:00-9:00 in Exley 103
Office Hours
scheduled and by appointment

About Imperative Programming

What do Computers do?


What is an Algorithm?


How can we Communicate an Algorithm to a Computer?


Programming Languages

A programming language is a formal language for representing and manipulating information and performing tasks.

An imperative programming language does this using sequences of instructions. (Do this, next do that…)

Why Learn to Program?

How to Learn Programming

Learning programming is a process,

to be successful, you need to invest time and attention.

Why Might Programming Seem Hard?

Syntax and Parsing

Natural languages tend to be complex and flexible:

To die, to sleep; to sleep, perchance to dream; aye, there’s the rub, for in that sleep of death, what dreams may come, when we have shuffled off this mortal coil, must give us pause.

Formal languages are typically simple but rigid:

for x in xs :
    acc += len (x)

Example: Parsing Arithmetic

3 + 4 × 5


3 + (4 × 5)


Note: although “$3 + (4 × 5)$” and “$(5 × 4) + 3$” have the same value, they are not the same expression!


Named for Al-Khwārizmī, a 9th c. Persian mathematician, astronomer and cartographer.

a complete description of a procedure for accomplishing some task.

Programming languages let us communicate algorithms to computers.

Upshot: the computers can do the work of carrying them out!

Historical note: a “computer” used to be a person.

Example: Evaluating Arithmetic

3 + (4 × 5)

steps to

3 + 20

steps to



About Python


Python is:

In this course we will use the Python language version 3.

Python, the Language

lots of users, platforms, libraries and tools
details of the underlying hardware, operating system, etc. are abstracted away

Python, the Platform

To Do This Week: