STEM: Programming for Kids – Step 1 User Input

So the project we are starting requires some understanding of the code blocks before we explode little minds into cramming them together to make something as cool as a translator, so let’s start at the beginning – User Input.

GOAL: Ask a user to enter their name and have your sprite say “Hello, name!”

Required:

An Event Block to get us started – the choice is yours. I will be choosing “When this sprite is clicked”

The Ask Block – This is how we will get our user to enter their name.

The Say Block – This will have our sprite print the answer (variable we received from the user) onto the screen. I have chosen the Say Block with time so we can decide how long it should remain on screen.

We will also need the Answer Block to put inside our say block.


After putting these basic blocks together we get something like this:

In the below test run, we entered our name as Julie and got this result:

What happened? We want it to say Hi, Julie!

Let’s take a look at our code:

And there it is! We only asked our program to say the answer our user gave us – Oops!!

Let’s see how we can fix it.

We will need the code block JOIN. A join, in programming, is usually referred to as concatenation. We concatenate (or join) things together.

In our case we want to join “Hi,” with the user’s name (answer). So in scratch it will look like this >>

Join Block

Let’s run it again and see what we get.

Here you will notice there is no space between “Hi,” and “Julie”.

We will need to add it because, computers will only do exactly what we tell them to and, we forgot. Oops again!

Add a space after the comma in our Join block and run your code again.


You should see something like this:

Leave a comment