Inputting Data

Inputting Data

In all the programs we have written so far, once we have clicked the Green Flag the program has followed the instructions we have given it and we have just sat back and watched.

We are now going to look at how we can make our programs more interactive so they respond to the user’s INPUT.

When you use an Ask Block the program pauses until the user has entered something into the waiting data entry box.

When the user presses enter or ticks the data entry box, then the program resumes.

What the user entered into the data entry box is now stored in a little block of memory in Scratch called 'answer'.

This block of memory can only hold one value at a time.

This example shows how a program can ask a question and say what was typed into the data entry box back to the user for two seconds.

The problem with the Answer block is that it can only hold one value at a time so if we had a program like this:

This is what happens....

When it says "Hello" it will say the age.

This is because the last value we told 'Answer' to be was the age.

To get over this problem we must use variables to store the individual answers to the questions. This allow the values to be used again and again.

Watch the video below to see how to use the ASK block to enter data into Scratch programs.

Scratch 6 - Input.mp4

Challenges

Write programs that will:

    • make Jane ask for two number then multiply them

    • make Jane ask for two numbers then divide them

Key Words

Input

Data that is entered into a computer system, this can be manually or by using sensors.

Files

Below are the files you will need to complete the challenges.