Instructing the computer with algorithms and flowcharts Lesson 1 Instructing the computer with algorithms and flowcharts
Algorithms Computers need to be programmed with what they must do, they cannot think for themselves! Algorithms are lists of instructions that computers ‘read’ and act upon.
You press the button on your computer…………. Computer looks for operating system (like Windows) and finds it Computer displays ‘loading’ message Computer finds all desktop icons Computer displays mouse cursor Computer awaits further instructions
Here is an example of an algorithm for making toast Take bread out of the packet Place bread in the toaster Select colour Push toaster button down Await toast popping up When it pops up, take it out Apply butter to the toast
Flowcharts Algorithms get turned into flowcharts so we can be precise when telling the computer what to do. Here is a simple example: start Read the board Open your planner Pick up a pen Write your hwk stop
Have students take out their laminated shapes and use the following statements to make a flowchart for cleaning teeth Run the cold tap Rub the brush on your teeth Spit out the paste Put the brush in your mouth Put toothpaste on Rinse your mouth out
Decisions!
When algorithms can go one way or another Sorry, do you take sugar? How many? Do you take milk? How much? Hmm this changes things!
Algorithms to flow charts start Algorithms to flow charts Boil water These start and end processes These start and end processes These start and end processes Add coffee This is a decision symbol, the flow can go one of two ways This is a decision symbol, the flow can go one of two ways This is a decision symbol, the flow can go one of two ways This is a decision symbol, the flow can go one of two ways This is a decision symbol, the flow can go one of two ways Sugar? yes Add sugar no Stir coffee These are used for actions These are used for actions These are used for actions These are used for actions These are used for actions end
This is a decision symbol, Turn a cup of coffee algorithm into a flow chart using the shapes supplied These start and end processes These are used for actions This is a decision symbol, the flow can go one of two ways Connect the shapes
Here is an algorithm for making the Scratch cat walk start no Don’t move Is right key pressed? yes Point right Move right 10 Is left key Point left Move left stop Here is an algorithm for making the Scratch cat walk Is right key pressed? Is right key pressed? Is right key pressed? Is right key pressed? Here it is as a flow chart yes yes yes yes yes yes yes no no no Don’t move Don’t move Don’t move Don’t move When the left key is pressed, point left and move 10 paces When the right key is pressed, point right and move 10 paces Point right Point right Point right Point right Point right Point right Point right Point right Point right Move right 10 Move right 10 Move right 10 Move right 10 Move right 10 Move right 10 Move right 10 Move right 10 Move right 10 Move right 10 Move right 10 Is left key pressed? Is left key pressed? Is left key pressed? Is left key pressed? Is left key pressed? Is left key pressed? Is left key pressed? Is left key pressed? Is left key pressed? Is left key pressed? Is left key pressed? Is left key pressed? Is left key pressed? Is left key pressed? Is left key pressed? Is left key pressed? Is left key pressed? Is left key pressed? Is left key pressed? yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes no no no no no no no no no no no no no no no no no Don’t move Don’t move Don’t move Don’t move Don’t move Don’t move Don’t move Don’t move Don’t move Don’t move Don’t move Don’t move Don’t move Don’t move Point left Point left Point left Point left Point left Point left Point left Point left Point left Point left Point left Point left Point left Point left Point left Point left Point left Point left Point left Point left Point left Point left Point left Point left Point left Point left Point left Move left 10 Move left 10 Move left 10 Move left 10 Move left 10 Move left 10 Move left 10 Move left 10 Move left 10 Move left 10 Move left 10 Move left 10 Move left 10 Move left 10 Move left 10 Move left 10 Move left 10 Move left 10 Move left 10 Move left 10 Move left 10 Move left 10 Move left 10 Move left 10 Move left 10 Move left 10 Move left 10 Move left 10 Move left 10 Move left 10 Move left 10 stop stop stop stop stop stop stop stop stop stop stop stop stop stop stop stop stop stop stop stop stop stop stop stop stop stop stop stop stop stop stop stop stop stop