{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Scratch2 - Scratch Averageproblem Averageproblem Variables...

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

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

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

View Full Document Right Arrow Icon
Average problem
Image of page 2
Average problem
Image of page 3

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

View Full Document Right 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.
Image of page 4
Average problem
Image of page 5

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

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

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

View Full Document Right 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:
Image of page 8
Checkbook Set initial position Ask user for balance Initialize balance Move to the right the appropriate amount
Image of page 9

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

View Full Document Right 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.
Image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern