# Lecture 1

1/16/2018

## Why Take This Class

• Computer programming is fun!
• Doodling
• The “Ahah Reaction”
• It will enhance your career.
• Sally has a BA in business
• Jane has a BA in business and some CS
• You will develop an intuition for what computers do.
• Very fast
• Very dumb
• Very precise
• Very obedient.

## Background and “Literary”" References

Let’s get acquainted with the creator and the community.

The name “Python” is a reference to the the comedy group Monty Pythons’s Flying Circus. Here’s a famous piece from one of their movies.

When you start Idle, know where the name came from.

## Use of Python

Python 3 is installed on all of the computers in the lab. You also probably want to install Python on your own laptop.

Be sure to install Python 3, not Python 2. You need to adopt a strategy for making what you do on one computer available on others. You could use either a USB drive or something like dropbox.

Start Python by running Idle. Demo.

## Numbers in Python

There are three types of numbers in Python, which we can use in pocket-calculator mode in the Python shell.

• Integers
• Floats
• Complex Numbers (We will rarely use these.)

## Integers

An integer is a number without a decimal point.

Operations

• Subtract: -
• Multiply: *
• Division: //
• Remainder: %
• Exponentiation

## Examples:

Run the following in the Python shell.

3+4
5-2
5*3
5//2
5**3
5%3

## Floats (Floating point numbers)

These are numbers with decimal points.

Operations

• Subtract: -
• Multiply: *
• Division: /
• Exponentiation

Note that the difference is really in division. The result is complete and no remainder exists.

## Examples of Division Difference.

Run the following in the Python Shell.

5//2
5%2

5/2

## Exercises

Do 1.1 through 1.5 on Page 13.

## Exercises

Do 1.9 through 1.12 on Page

## Naming objects

We can use an assignment statement to give names to our numerical objects. Then we can use the names in place of the actual objects in subsequent work.

See example in Session 1.5

## What happens to the value of y after the following sequence of assignments.

x = 3
y = x**2
x = 4

x = 3
y = x**2
x = 4
print(y)
## 9

## Rules for Names

Names may contain only three things.

1. Letters
2. Numbers
3. The underscore “_"

A name may not begin with a number.

Names are case sensitive.

You must not use the reserved words in Table 1.1 as names.

## Exercises

Do Problems 1.17, 1.18, 1.20 and 1.21.