Scratch is a free visual programming language developed by the MIT Media Lab. The ability to code computer programs is an important part of literacy in today’s society. When people learn to code in Scratch, they learn important strategies for solving problems.


Variables

What is a variable?

Picture3

  • Variable is a location in memory, that stores a value, that can change as the program is running.
  • Think of it like a shoe box, that you give a label and put data inside.

Please load Scratch and have a go at the following tasks that will help develop your understanding and ability to use variables in programming…

Using variables in Scratch…

Like all programming languages, Scratch allows us to store data in variables and manipulate it. The program below will ask the user to INPUT a number, assign it to (put it in) a variable and then OUTPUT the number multiplied by itself.

s1

01) Can you create a program like the one shown above that will OUTPUT the number multiplied by 10. So if the user INPUTS 10, your program should OUTPUT 100.

 

 

02) Can you create a program that will ask the user to INPUT 2 numbers and OUTPUT the numbers added together.

03) Can you create a program that will ask the user to INPUT a number and will OUTPUT its square root.

 

 

04) Can you create a program that will ask the user to INPUT a decimal number. Your program should then OUTPUT the number rounded to the nearest whole number.

05) Can you create a program that will allow the user to INPUT a word. Your program should then OUTPUT the length of word.

 

 

06) Can you create a program that will the user to INPUT their name and then will OUTPUT a welcome message.

 

 

07) Can you create a program that will ask the user to INPUT their name and their age. Your program should then OUTPUT a message, depending on their age, telling them if they are old enough to vote in the general election.

 

 

This slideshow requires JavaScript.

 

 

This slideshow requires JavaScript.


Iteration