Idea 4of 23Builds onA variable holds one number
Same code, new input
What changes when you run the same code on another number?
Today you'll discover
- where an input goes
- how to run code on any input
- where an input can come from
Think firstNo SET this time: the code starts with the input
The input 3 goes into the box first. What does the code output?
Decide first, then press Next. Put the input in the box, then run each line.
Three blocks of code: ADD 5, MULTIPLY BY 2, OUTPUT, beside a box holding the input 3. A table fills in: 3 to 8, then 8 to 16, and OUTPUT shows 16. Then the same code runs with the input 10: 10 to 15, then 15 to 30. The last step asks about MULTIPLY BY 3, ADD 2 with an input of 6 teams.
See the whole ideathe big idea and the key word, in one place
The big idea
Run the same code on a new input and the same lines give a new output.
One program, many inputsADD 5, then MULTIPLY BY 2: input 3 gives 16, input 10 gives 30, input 0 gives 10.
Where inputs come fromAn input can be a count, a reading from a sensor such as a thermometer, or a number a person types in.
Key word
- run
- to have a computer do the lines of code, one after another; also called executing the code
Ready to use it?
- Run a program on different inputs and fill in a table of outputs.