Scratch2 - Scratch Workingwithvariables Averageproblem...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
Scratch Working with variables
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Average problem
Background image of page 2
Average problem
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Variables In programming, a variable is a placeholder for some value. In Scratch, variables are represented with blocks shaped like elongated circles, uniquely labeled by you. Variables can be local or global . In Scratch, a local variable can be used by just one sprite; a global variable can be used by all of your sprites.
Background image of page 4
Average problem
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Sample programs: Balancing a checkbook Get Balance Deposit Withdraw
Background image of page 6
The program Variables? Operations? Results
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Checkbook The variable balance accumulates values Initialize this to 0 And then add to that value an amount input by user. Or set its initial value to an amount input by the user:
Background image of page 8
Checkbook Set initial position Ask user for balance Initialize balance Move to the right the appropriate amount
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Checkbook Deposit amount (press 'd') Ask user for amount Add that amount to balance Balance = balance + answer Move from present position to the right . Do not move up/down.
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 20

Scratch2 - Scratch Workingwithvariables Averageproblem...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online