Lecture 1

Harold Nelson

1/16/2018

Why Take This Class

Background and “Literary”" References

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

https://www.youtube.com/watch?v=YgtL4S7Hrwo

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.

https://www.youtube.com/watch?v=IMxWLuOFyZM

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

https://www.youtube.com/watch?v=mL7n5mEmXJo

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.

https://www.python.org/downloads/

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

An integer is a number without a decimal point.

Operations

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

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

Answer

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.