# Unplugged: What's your function & crazy conditionals
Materials
* Pencils
* Paper (or index cards)
![Inputs process outputs](/static/courses/csintro/algorithms/inputs-process-outputs.png)
In computer programming, algorithms are sets of instructions.
Algorithms ‘tell’ the computer how to process input and what, if any, output to produce.
An example of an algorithm you have seen in math class is the ‘function machine’.
![Inputs function output](/static/courses/csintro/algorithms/input-function-output.png)
A function machine takes an input, processes the input, and then delivers an output.
The inputs and their outputs are usually recorded in an input output table, where the value of x represents the input and the value of y represents the output. See example.
```
Input (x) Output (y)
======================
1 2
2 4
3 6
4 8
```
A common math problem is to determine what processing is happening to the input that results in the given output. In the example above, each input is being doubled (multiplied by 2) to produce the corresponding output.
```
Input (x) Processing => Output (y)
======================================
1 * 2 2
2 * 2 4
3 * 2 6
4 * 2 8
```
## Unplugged: What's your function?
For this activity, the students can work in pairs, Player A and Player B. The pairs will take turns being the function machine for their partner who will be providing input to be processed.
Direct the students how you would like them to record their work.
They can use pencil and paper or index cards.
On paper, they can keep track of inputs and outputs in a table (see example above).
With index cards, Player A can write each input on one side of an index card, hand the card to Player B, who then writes the corresponding output on the other side of the card.
* Player B decides on a mathematical function or bit of processing* that will be done on whatever input she receives from Player A.
* Player B should write down the function or bit of processing and set it aside, out of sight of Player A.
* Player A then gives Player B a number to process.
* Player B processes the number and returns an output to Player A.
* Player A can then state what function or bit of processing she thinks Player B is using on the input to produce the given output. One try per round of input/output.
* If Player A states the correct function, Player B confirms that it is correct by showing the previously hidden function and the players switch roles and start the game over.
* If Player A does not guess correctly, Player A provides another input that Player B processes and provides an output for.
* The goal is for Player A to figure out what function or bit of processing Player B is using in the fewest number of rounds of input/output possible.
* After each student has had at least one chance to be the function machine, play more rounds as time permits.
* The difficulty level of the possible functions should be determined by the teacher and shared with the students ahead of playing. Alternately, the teacher can provide function cards that are handed out at random to be used by the players, rather than the players creating their own.
* The player providing the input should not just guess what the function is. She should be able to explain why she thinks her input resulted in the given output.
* Examples of ‘easier’ functions:
> * [ ] Add 8
> * [ ] Subtract 6
> * [ ] Multiply by 3
> * [ ] Divide by 2
* Examples of more difficult functions:
> * [ ] Multiply by 2 and then subtract 1
> * [ ] Square the input
> * [ ] Return 20% of the input
## Unplugged: Crazy Conditionals
This is a fun, interactive exercise to introduce conditionals and event handlers as computer processing. Read through the entire activity and adjust as needed for your class and classroom.
* Print & cut into strips with one conditional on each strip
* Note that some of the same conditionals can be given to multiple students, while other conditionals are to be given to just one student.
* Except for the first ‘BEGIN’ conditional, hand out the conditionals PRINT SIDE DOWN.
* Besides the ‘BEGIN’ and ‘STOP’ conditional, give at least two other conditionals to each student. A lesson from this is that it is challenging for a student to keep track of a lot of different conditionals, though not so for a computer! : )
* Add AND, OR, AND/OR statements to the conditionals.
* Create nested IF’s
* Let students create the IF’s
* Relate this activity to a system and have the students create the conditionals that would end in a product of some kind or the completion of some task.
Give these 2 conditionals to all students.
* These 2 conditionals will be triggered only once.
* These conditionals start and stop this activity.
* Give the first ‘BEGIN’ conditional to the students PRINT SIDE UP.
**IF** the teacher writes the word ‘**BEGIN**’ on the whiteboard,<br/>
**THEN** flip over the conditionals in front of you and follow the directions.
**IF** you see the word ‘**STOP**’ on the whiteboard,<br/>
**THEN** sit back, cross your arms, and look at the teacher (smile!).