Tải bản đầy đủ (.ppt) (14 trang)

3 calculations SCRATCH

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (580.78 KB, 14 trang )

Section 3
Calculations
National 4/5
Scratch Course


What you should know after this
lesson





How scratch stores numbers
How to use variables in calculations
What operators do
The importance of sequence in calculations


Variables
These are storage locations in RAM, controlled by
the programming language.
What types of data might we need to use with our
programs?
The main ones we will be using are
– Numeric
– String


Numeric
• Are used for calculations.


• If you need to use a piece of data in a
calculation you should use a number variable.


Scratch Variables
The scratch language is able to work out the type
of variable we are using and as a result it only
has the one type of variable

1. Click on the variables tab
2. Click “Make a variable”
3. Type the name you want
to use for the variable


Displaying Variables
• We can get any sprite to speak by using the say
block from inside looks.
• Variables can be displayed on the stage for
example to display information useful to the user.


Calculations
• For this task we are going to add two numbers
together
• Create a new scratch project and add two new
variables called first and second
• Add the script shown below
Copy the program into
your jotter and

answer.
1. What does the
program do?
2. Why do we need
First & Second?


Other Operators
• Copy the blocks on the right
into your jotter.
• Write beside each one what
it does
• How could we do bigger
calculations?


Combining Operators
• Scratch Operator blocks (+*/) can be combined to make
more complex calculations.
• Simply drag a block into the
white box.
• Remember the BODMAS
rules from maths.









Brackets ()
Of ^
Division /
Multiplication *
Addition +
Subtraction -


Task




Calculate the
answer to the
following problems,
write the answers in
your jotter. (you can
use a calculator)
Enter the
calculations into
scratch and check
your answers

1.
2.
3.
4.
5.

6.
7.

5+4
5*4
5+4-3
34+3*6
(34+3)*6
40/5 + 4
4+40/5


How can we get it to display the full
sum as the answer?
• You can add join to join to make a longer
sentence.
• To drag the whole script block drag the
lowermost block.
• Edit the program to subtract, multiply & divide.
Save it in your network area.


Assignment of variables
• Variables can be assigned values using the set
block.
• Variables can be assigned the results of a
calculation as well as the answer to an ask
block.



Review Questions
Copy and answer these questions in your jotter.
1.
2.
3.
4.

Where does scratch store numbers?
What is assignment?
What do arithmetic operators do?
Why is the sequence of calculations important?


Tasks
Create scratch programs to do the following (save
each in your network area).
1.
2.
3.
4.

Calculate the area of a rectangle
Calculate the square of a number
Calculate the sum of three numbers
Calculate the average of three numbers



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×