## Presentation on theme: "Scratch Programming Lesson 4 Question asking and answering."— Presentation transcript:

We are going to learn… How to ask a question and receiving answer First touch of variable – answer Creating variables How to use If….. Else loop…. Forever IF vs. If Broadcast

Variable What is variable? A storage location of some value or words is a variable When we ask more than one question, the latest one will over-write the previous one More variables are needed for storage

Creating variables Click here to create a new variable This box will pop-out and name should be given to the variable Choose the target user of the variable

How to use variable To control whether the variable will be displayed on the stage Give a value to the variable Change the value of a variable by a certain number

Operators (Part I) Addition, Subtraction, Multiplication and Division Smaller than, equal to OR greater than String- a sequence of characters String functions, 1) Join two strings together 2) Select one letter from the string depending on the position of the letter 3) Return the length of the string

If… else If the operation in returns a TRUE value, the commands here will start to run. If the operation in returns a FALSE value, the commands inserted here will start to run.

Forever If vs. If Forever If ▫Non-stop to check the condition If ▫Just check the condition once

Forever If vs. If Once the green flag is pressed ▫Would play meow sound whenever the mouse point to the sprite Would play meow sound only when the mouse point at the time and the green flag is pressed at the same time

Broadcast Generate a message to the program Set an object ( actor / background) to response when a message is broadcast by others

How to use Broadcast The sprite gives a broadcast signal: change The stage changes to another background when receive the “change” signal

Task of the lesson Start a new program In this program, the sprite can help you calculate 3 questions The green flag will be the program starter Input: ▫Tell the user that you are going to help them in ▫Allow the user to input 2 numbers, one by one Output: ▫Return “Correct!” if you have the correct answer and change to another background with a background music ▫Return “Wrong!, the answer is ___” to return the correct answer to the user ▫The outputs will be displayed 2-3 seconds Save your program and upload as Program4_3_ _ _ in eclass