## Fundamental Equation of Computers

The fundamental equation of computers is:

• CPU chip in the computer runs "machine" code
-Billions of machine "operations" per second
• Stupid
-Machine operations are simple and mechanical
-e.g. a = b + c
-Nothing like "insight" or "thinking"
-Insight= human programmer, CPU just runs their code

## Programming

• Programmer write the code (e.g. Python)
• Python code is translated to machine code
• CPU runs that
• Code has weirdly inflexible syntax (see below)
• This reflects the CPU's limitations .. inflexible!
• e.g. grocery list

## Key Preface: Thinking About Syntax Errors

• Syntax -- code is structured for the computer
• Very common error -- type in code, with slight syntax problem
• Professional programmers make that sort of "error" all the time
• Fortunately, very easy to fix ... don't worry about it
• Not a reflection of some flaw in the programmer
• Just the nature of typing ideas into the mechanical computer language
• Beginners can be derailed by syntax step, thinking they are making some big error
• Exercise to inoculate you all: a bunch of typical syntax errors + fixing them
• Fixing these little errors is a small, normal step

## Binky Introduction

• "Binky" code toy we'll use for a couple days
• Binky is a robot in a 2d world
• Binky has very simple capabilities
• Introduce a few code ideas this way

## Binky Verbs

• Things the robot can do:
• move()
• left()
• right()
• paint('blue')
• # 'red' and 'green' work too

## Binky Code Example1

```def fun(binky):
binky.move()
# binky just moved forward one square
binky.paint('blue')
```

## Example1 Points

• "def" - defines a function
-named "fun" in this case
• function run the lines inside from top to bottom
• "binky" refers to a binky object (noun)
• "binky.move()"
-run the "move()" function of binky
-noun.verb style
• # - a comment, computer ignores the rest of the line
• This all looks weird, but is essentially simple

Try Some Parlante.org Exercises... (first time used ever)

## Run Code -- Get Errors -- Fix!

• Not grading these, just for demos and to get your feet wet
• binky1 - this one works
• binky2
• binky3
• binky4
• binky5
• binky6
• binky7
• Main syntax points:
• -noun.verb() must be exactly right
• -start/end quote marks required
• -indention straight, not ragged
• -sometimes the error message has the right line number