+ All Categories
Home > Documents > Scratch Programming

Scratch Programming

Date post: 17-Jan-2016
Category:
Upload: satin
View: 76 times
Download: 0 times
Share this document with a friend
Description:
Scratch Programming. Lesson 4 Question asking and answering. 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. Question asking and receiving answer. - PowerPoint PPT Presentation
Popular Tags:
13
Scratch Programming Lesson 4 Question asking and answering
Transcript
Page 1: Scratch Programming

Scratch ProgrammingLesson 4Question asking and answering

Page 2: Scratch Programming

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

Page 3: Scratch Programming

Question asking and receiving answer

Input answer here

The answer will be stored in the “answer” variable

Page 4: Scratch Programming

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

Page 5: Scratch Programming

Creating variablesClick 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

Page 6: Scratch Programming

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

Page 7: Scratch Programming

Operators (Part I)Addition, Subtraction, Multiplication and Division

Smaller than, equal to OR greater than

String- a sequence of charactersString functions, 1) Join two strings together2) Select one letter from the string depending on the position of the letter3) Return the length of the string

Page 8: Scratch Programming

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.

Page 9: Scratch Programming

Forever If vs. If• Forever If

▫ Non-stop to check the condition

• If▫ Just check the condition

once

Page 10: Scratch Programming

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

Page 11: Scratch Programming

Broadcast

• Generate a message to the program

• Set an object ( actor / background) to response when a message is broadcast by others

Page 12: Scratch Programming

How to use Broadcast

The sprite gives a broadcast signal: change

The stage changes to another background when receive the “change” signal

Page 13: Scratch Programming

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


Recommended