## Class 3 – Monday, January 22

## March on even though it’s September

Together we learn — To say what we mean to say — A skill to treasure

### Look both ways

### What makes me happy

- I think last class was the best Class 02 ever.

### Examples from last class – any questions?

### We all haiku

### We are star dust

### Examples of the day – please download now

- Introduces the notion of guidelines and standard practices

- See guide

- Program contains several errors that need to be fixed

- Introduces numeric types
`int`

and`float`

. They are respectively the type of values Python uses for integers and decimals.

- The Python arithmetic operators are: addition:
`+`

; subtraction:`-`

; multiplication:`*`

; decimal division:`/`

; integer division:`//`

; exponentiation:`**`

; remaindering:`%`

- If one of the operands of an arithmetic operation is decimal, the result is decimal; otherwise, the result is integer except for decimal division.

- Introduces the string type.

- Introduces the
`import`

statement. By the way,`import`

is a Pythonkeyword. Keywords are not allowed to be used to name things. Keywords are reserved by Python for special usage. Keyword`import`

tells Python amodule(library) is should be set up as a program resource.

- Also introduces the
`.`

operator. The operator is typically called thedotorselection operator. The`.`

tells Python that an element of the resource to its left is having one of its components (the one to its right) being selected for use.`

### Shape your future

- Influence the problem sets we consider this semester. It is our intention to choose problems the best we can that interest
*all*students. It is known that faculty and student interests can differ.

### Agenda

- Continue our exploration of digital problem solving

- Expand our communication and abstraction skills

- Begin an appreciation for writing readable code

- Look at our haiku gallery

- Introduce additional programming concepts

- Introduce variables

- Introduce integer and decimal operations

- Introduce additional terminology to which you should become accustomed

• Variable • Value • Operator • Decimal division • Integer division • Remainder • Mod • Type `int`

• Type `float`

### To do list

- Review class artifacts

*Read and Reread*

- The Coder's Apprenctice : sections 3 – 4, and/or

- How to Think Like a Computer Scientist: Learning with Python 3: Sections 10.2 – 10.11

- Complete the homework

### Take aways

- A video examining the insand outs of a first program

- There are two forms for the
`print()`

function

- A
`print()`

statement with an empty parameter list produces an empty line of output

- A
`print()`

statement with one or more comma-separated values produces a line of output composed of the values with a single space separating one value from the next

- A literal string is a sequence of characters with in quotes (can be single or double)

- Python has two string operators

- Concatenation:
`+`

- Takes two strings
sandtand produces a new string by first copyingsand immediately following it with a copy oft

- Duplication:
`*`

- Takes its integer
noperand and its string operandsand produces a new string that isncopies ofs

- Python allows integer and decimal arithmetic operations

- Addition:
`+`

- Subtraction:
`-`

- Multiplication:
`*`

- Decimal division:
`/`

- Integer division:
`//`

- Exponentiation:
`**`

- Remaindering:
`%`

- If one of the operations of arithmetic operation is decimal, the result is decimal

- If an
*expression*has more than one operation, the Python will

- First do any exponentiation operations

- Next do any multiplication, division, or remaindering operations going from left to right

- Then do any addition or subtraction operations going from left to right

- Our computers are limited in how much information they can store. Python recognizes that not all integers and decimals can be represented because there is only finite amount of memory in a machine

- Python has a type
`int`

. This type is for representing the best it can do with integers

- Python has a type
`float`

. This type is for representing the best it can do with decimals. With a 64-bit operating system, the`float`

can support at must 15 digits of precision

- Python has a type
`str`

. This type is for representing sequences of charactes.