Comp 112

Lecture 1

Course Introduction

2017.01.31

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

Lecture
weekly (Tuesdays, 8:50am, Shanklin 107)
Lab
weekly (time/place varies by section)
Reading
free online book: Think Python (2nd ed.). Readings assigned weekly.
Homework
weekly (released to Moodle shortly after each lecture, due by beginning of following lecture)
Exam
two midterms (in lieu of lectures on March 7 and May 9)
Programming Project
in lieu of final exam at end of semester (details to follow)

Course Resources

Lab
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 74
Office Hours
scheduled and by appointment

About Imperative Programming

What do Computers do?

(discussion)

What is an Algorithm?

(discussion)

How can we Communicate an Algorithm to a Computer?

(discussion)

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.

advantage: intuitive and familiar

disadvantage: dealing with implicit state

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

means

3 + (4 × 5)

or

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

Algorithms

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

Algorithm
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

23

or

About Python

Python

Python is:

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

Python, the Language

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

Python, the Platform

To Do This Week: