1 Scratch Material
1 Scratch Material
1. Introduction
Scratch is a free, high-level, block-based visual
programming language and website where you can create
your own interactive stories, games, and animations.
With a sprite selected at the bottom of the staging area, blocks of commands can be applied to it by dragging them from
the block palette into the coding area. The Costumes tab allows users to change the look of the sprite in order to create
various effects, including animation. The Sounds tab allows attaching sounds and music to a sprite.
When creating sprites and also backgrounds, users can draw their own sprite manually, choose a Sprite from the library,
or upload an image.
Quiz 1
2 objectives and 1 theory from each section.
1. Programming Basics
Programming is writing computer code to create a program, in
order to solve a problem. To program a computer, you need to
know how programs are constructed.
2. Algorithm
An algorithm is a list of steps you give a computer to solve a
problem or to get something done.
In coding, programmers write algorithms that instruct the
computer how to perform a task.
We use algorithms are every day and everywhere. A process for
making Indomie is an algorithm, the method you use to solve
addition is an algorithm, and the process of folding a shirt or a pair of trousers is an algorithm.
Write the algorithm to prepare Indomie.
Quiz.
1. Variables
In coding, variables are containers for storing data values.
You can think of a variable as a box that contains something.
You can open the box to find out what is inside, or even put
something else into the box. Variables can change when the
user is asked a question, for example, their age.
Quiz
1. Data Types
A data type determines what type of value an object can have and what operations can be performed. Variables can
store data of different types, and different types can do different things. In programming, there are 5 basic data types:
string, character, integer, float and Boolean.
s/n Data Type Description Used for Example
1 String Used for a combination of one or more characters that Alphanumeri -Anietie
appear on a keyboard, such as letters, numbers and symbols. c characters -8th August, 2021
A string represents alphanumeric data. This means that a -08/08/2021
string can contain many different characters, but they are all
considered as if they were text, even if the characters are
numbers.
2 Character A character is a single symbol, which can be a letter, a digit, a Encoding text -9
symbol, or a Chinese character, etc. numerically -&
-a
3 Integer An integer is a number with no decimal places. Whole -1
Integers are whole numbers and can be positive or negative. numbers -990
4 Float Used for numbers that contain decimal points, or for Number with -0.5
fractions. a decimal -96.103
point
5 Boolean Used where data is restricted to True/False or yes/no Representing -True
options. logical values -False
Quiz.
1. Concatenation
Concatenation means joining two strings
together. In many programming languages,
the symbol used for concatenation is a plus
( + ). A common use of concatenation is
when you want to display a message that
includes the value of a variable.
In Scratch, we can join values (concatenate)
using (join () ()) in the Operators Block.
Quiz
1. Operators
An operator is a symbol that tells the program to perform specific
mathematical, relational or logical operation and produce final result.
For example 2 + 3 = x. The + and the = are called, operators.
Operands are the values used in these expressions, (2, 3 and x).
2. Types of Operators
There are mostly three types of operators:
1. Arithmetic operators
2. Relational operators
3. Logical operators
3. Arithmetic operators
Arithmetic operators allow arithmetic to be performed on values. The 4 arithmetic operators in scratch are:
s/n Arithmetic Operator Symbol Description Example
1 Addition + Adds two operands 30 + 5 will give 35
2 Subtraction - Subtracts second operand from the first 30 – 5 will give 25
3 Multiplication * Multiplies both operands 30 * 5 will give 150
4 Division / Divides numerator by de-numerator 30 / 5 will give 6
7. Relational operators
Relational operators allow for assignment and enable comparisons to be made. They
are used in condition testing. The 3 relational operators in scratch are:
s Relational Sy Description Example
/ Operator mb
n ol
1 Assignmen = Sign and assigns a variable a = 30
t
2 Greater > Checks if the value of left 30 > 5 is
than operand is greater than the true
value of right operand, if yes
then condition becomes true.
3 Less than < Checks if the value of left 30 < 5 is
operand is less than the value false
of right operand, if yes then
condition becomes true.
8. Logical operators
Logical operator help us take decisions based on certain conditions.
They are used to combine relational operators to give more complex decisions. The 3 logical operators in scratch are:
s/n Logical Operator Symbol Description Example
1 And and Returns True if both statements are true. (30 < 5 and 11 > 10) false
2 Or or Returns True if one of the statements is true. (30 < 5 and 11 > 10) true
3 Not not Reverse the result, returns False if the result is (true) false
true
9. Boolean
Booleans are data type that can contain either the value true or false.
Boolean statements are statements that evaluate to be true or false. An example of this might be 13 + 14 = 27, because
the statement evaluates to true, or 13 + 14 = 10, because the statement evaluates to false.
Boolean also refers to a system of logical thought that is used to create true/false statements. Boolean expressions use
the operators AND, OR, XOR and NOT to compare values and return a true or false result.
Quiz
1. Conditional Statements
A conditional statement tells a program to execute different actions
depending on whether a condition is true or false.
If a certain condition is true then a block of statement is executed otherwise
not.
In Scratch, we can write conditional statements using (if () then, if () then-else) in the Controls Block.
1. Procedure
A procedure is a small section of a program that performs a
specific task. Procedures can be used repeatedly throughout a
program. A real-life example of a procedure is brushing your
teeth. Another example of a procedure is cracking eggs into a
bowl and beating them before scrambling them in a pan.
4. Settings
1. Subject: Maths, English, Science, CRK, ICT.
Grade: A, B, C, D, F.
2. A = 80% - 100% (greater than 79.99% and less than 100.01%)
3. B = 70% - 79% (greater than 69.99% and less than 79.999%)
4. C = 60% - 69% (greater than 59.99% and less than 69.999%)
5. D = 40% - 59% (greater than 39.99% and less than 59.999%)
6. F = 0% - 39% (greater than -0.01% and less than 39.999%)
Teacher Comments
7. A = Your GRADE is A. Excellent result! You are the best.
8. B = Your GRADE is B. Very good result. Keep it up.
9. C = Your GRADE is C. Good result. Keep improving.
10. D = Your GRADE is D. Average result. But I know you will do better.
11. F = Your GRADE is F. Below average result. You can do better.
1. Loops
In coding, a Loop is a command used to repeat a part of code until the desired process
is complete. A loop is used for executing a block of statements repeatedly until a
particular condition is satisfied. Typically, a certain process is done, such as getting an
item of data and changing it, and then some condition is checked such as whether a
counter has reached a prescribed number.
2. Types of loops
There are three main types of loops: for loops, do loops and while loops.
In Scratch 3.0, some of the blocks used to represent a loop process are, forever, repeat
(10), repeat until, all found in the control blocks.
1. Broadcast.
One method to direct the timing of events in a coding
project is to broadcast a message in Scratch. Broadcasting
sends a message to one or more sprites. The message is
used to trigger a script to run.
Broadcast is found in Events Block.
2. Text-To-Speech
Text-To-Speech turns text into natural-sounding speech in
different languages and different voices.
Use (Add Extension) to add the Text-To-Speech Block.
4. Settings
12. Subject: Maths, English, Science, CRK, ICT.
Grade: A, B, C, D, F.
13. A = 80% - 100% (greater than 79.99% and less than 100.01%)
14. B = 70% - 79% (greater than 69.99% and less than 79.999%)
15. C = 60% - 69% (greater than 59.99% and less than 69.999%)
16. D = 40% - 59% (greater than 39.99% and less than 59.999%)
17. F = 0% - 39% (greater than -0.01% and less than 39.999%)
Teacher Comments
18. A = Your GRADE is A. Excellent result! You are the best.
19. B = Your GRADE is B. Very good result. Keep it up.
20. C = Your GRADE is C. Good result. Keep improving.
21. D = Your GRADE is D. Average result. But I know you will do better.
22. F = Your GRADE is F. Below average result. You can do better.
.
.