Presentation is loading. Please wait.

Presentation is loading. Please wait.

Section 3 Calculations National 4/5 Scratch Course.

Similar presentations


Presentation on theme: "Section 3 Calculations National 4/5 Scratch Course."— Presentation transcript:

1 Section 3 Calculations National 4/5 Scratch Course

2 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

3 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

4 Numeric Are used for calculations. If you need to use a piece of data in a calculation you should use a number variable.

5 Scratch Variables 1.Click on the variables tab 2.Click “Make a variable” 3.Type the name you want to use for the variable 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

6 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.

7 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?

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

9 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 -

10 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.5+4 2.5*4 3.5+4-3 4.34+3*6 5.(34+3)*6 6.40/5 + 4 7.4+40/5

11 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.

12 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.

13 Review Questions Copy and answer these questions in your jotter. 1.Where does scratch store numbers? 2.What is assignment? 3.What do arithmetic operators do? 4.Why is the sequence of calculations important?

14 Tasks Create scratch programs to do the following (save each in your network area). 1.Calculate the area of a rectangle 2.Calculate the square of a number 3.Calculate the sum of three numbers 4.Calculate the average of three numbers


Download ppt "Section 3 Calculations National 4/5 Scratch Course."

Similar presentations


Ads by Google