Minds On
Discover Scratch

Press Scratch(Opens in a new window) to access a code. Click the green flag at the top to run the code and find out what happens!
The following is a screenshot of the code provided from the link:

The sequence of code is as followed: when the green flag is clicked the program is started. The sprite asks “What is your age?” and the sprite waits for a response from user. Then set userAge to the answer by the user. If userAge is greater then the message “You are old enough to vote” is shown for 3 seconds. Else, the message “You are not old enough to vote yet.” Is shown for 3 seconds. The code is then executed completely.
Using a method of your choice, respond to the following prompts as you explore the code:
- Describe what you think the purpose of the program is.
- What sort of hints helped you to figure out the purpose of this program?
- What happens if you type in 16 as a response to the question asked in the program?
- What happens if you type in 19 as a response to the question asked in the program?
Action
Conditional statements
Revisit the same Scratch link provided for Mind On.
What you are exploring is a conditional statement being used in the code.
Conditional statements help a computer to make a decision. The conditional statement is:
if userAge > 17 then
Say “You are old enough to vote”
else
Say “You are not old enough to vote”
end if
In this case, the decision was to say either “You are old enough to vote” or “You are not old enough to vote.” The computer based this decision on the age entered by the user.
The language used is a pseudocode–an informal way of describing a computer program or algorithm that is an intermediary between everyday language and programming code.
The pseudocode for this program is:
When Start program
Ask: What’s your age?
Set userAge = answer
if userAge > 17 then
Say “You are old enough to vote”
else
Say “You are not old enough to vote”
end if
Part 1
Your local library is offering an online course: Safety Course for Staying Home Alone. You have to be 9 years of age or older in order to participate in the course.
The librarian asks you to write a program to let someone know if they can participate in the course or not.
1. Referring to the pseudocode above for Voting Age, identify which lines need to be altered to indicate whether someone is old enough or not to participate in Safety Course for Staying Home Alone. Record your changes to the pseudocode so that it can be used for the Safety Course for Staying Home Alone.
2. Revisit the code that you explore in the Minds On section. Press Scratch(Opens in a new window) to access this code. Alter the Scratch code to indicate whether someone is old enough or not to participate in Safety Course for Staying Home Alone.
3. Run your program and test it with different numbers. Does it work as you intended? If it doesn’t, what changes will you make so it does work as you intended?
Part 2
Let’s check out a new program. Press Scratch(Opens in a new window) to access this code. Click the green flag at the top to run the code.
1. Describe what you think the purpose of this program is.
2. What sort of hints helped you to figure out the purpose of this program?
3. The computer generates a new number each time. Are you able to ever guess the correct number?
The pseudocode for this program is:
When Start program
Set computerNumber = random value between 1 and 5
Ask: Guess a number between 1 and 5
Set userGuess = answer
if computerNumber = userGuess then
Say “You are correct”
else
Say “You are incorrect. Play again. I’ll come up with a new number.”
end if
4. Let’s make the game more challenging. Alter the pseudocode so that the number the computer comes up with is between 1 and 10 instead of 1 and 5.
When Start program
Set computerNumber = random value between 1 and 5
Ask: Guess a number between 1 and 5
Set userGuess = answer
if computerNumber = userGuess then
Say “You are correct”
else
Say “You are incorrect. Play again. I’ll come up with a new number.”
end if
5. Access the same Scratch(Opens in a new window) code and alter it to change the range of the number the computer will come up with.
6. Run your program. Does it work as you intended? If not, what changes will you make so it does work as you intended?
Consolidation
Write your own program
Recall from grade 4:
- An obtuse angle is an angle that is greater than 90 degrees.
- An acute angle is an angle that is less than 90 degrees.
- A right angle is equal to 90 degrees.
1. You would like to write a program that tells the user whether their angle is obtuse, acute or a right angle. Complete the pseudocode for this program.
When Start Program
Say “Enter an angle between 0 and 180 degrees”
angle = answer
if angle > 90 then
Say “(Blank)”
end if
if angle < 90 then
Say “(Blank)”
end if
if angle = 90 then
Say “(Blank)”
end if
2. Press Scratch(Opens in a new window) to access the code. Complete the code to create an angle checking program like the one above in the pseudocode above.
3. Run your program. Does it work as you intend?
If not, what changes will you make so it does work as you intend?
Reflection
As you read through these descriptions, which sentence best describes how you are feeling about your understanding of this learning activity? Press the button that is beside this sentence.
I feel...
Now, record your ideas using a voice recorder, speech-to-text, or writing tool.