Mathematics Scratch
Expert
45 mins
Teacher/Student led
+155 XP
What you need:
Chromebook/Laptop/PC or iPad/Tablet

Around the World part 2

In this project we will do some math to calculate how long it would take to walk, drive or fly all the way around the world! This project comes in 2 parts, this part 2.

Teacher Notes Lesson Files

Live Class Feed

This is a live feed of the latest activity by your students on this lesson. It will update in real-time as they work on the lesson.
Load previous activity

    1 - Complete part 1 of this project

    In a separate lesson you should have completed part 1 of this project. Open your project in Scratch and continue to the next step in this lesson.

    2 - Create a 'round decimals (number)' custom block

    As our formulas are using division, we may end up with answers that have many decimal places. For example:

    40,075 / 1,086 = 36.90147329650092

    To make things easier to read we will round these numbers to 2 decimal places, so the answer to the above sum would appear as 36.90.

    We will be rounding our answers several times so to makes things easier for us we will create a custom block that has all the code for rounding a number to 2 decimal places.

    In the My Blocks toolbox, create a new block called 'round decimals' and give it a number input called 'number'.

    Once you've created the block give it the following code. This does the following:

    1. Multiply the number by 100 (e.g. 36.90147329650092 x 100 = 3,690.147329650092)
    2. Round the amount to the nearest whole number (e.g. 3,690)
    3. Divide the amount by 100 (e.g. 3,690 / 100 = 36.90)

    definerounddecimalsnumbersetamounttonumber*100setamounttoroundamountsetamounttoamount/100



    3 - Create a 'calculate (type) (speed)' custom block

    We will also create a custom block that performs our calculations to work out the time in hours and in days and says the answers on the screen.

    In the My Blocks toolbox, create a new block called 'calculate' with a text input called 'type' and a number input called 'speed'.

    Once you've created the block give it the following code.

    definecalculatetypespeedsayjoinjointype travel at joinspeed kilometers per hour ...for3secondsrounddecimalsearth/speedsayjoinSo it would take joinamount hours to go all the way around!for3secondsrounddecimalsearth/speed/24sayjoinThat's joinamount days!for3secondsdefinerounddecimalsnumber



    4 - Receive the messages and calculate

    Our last step is to add some code to receive the messages and run the calculations. Depending on which message we receive we will use the calculate block and pass in the name and the speed that it travels.

    Add the following code to the earth sprite.

    whenIreceivepersoncalculatePeople5 we walk at 5 km per hourwhenIreceivecarcalculateCars100 100 km per hour for carswhenIreceiveplanecalculatePlanes5 1,086 km per hour for planeswhenIreceivespace stationcalculateThe international space station277724 The international space station travels at 277,724 km per hour!definecalculatetypespeed


    5 - Test it out!

    That's all the code for the project! Test it out by clicking the green flag and then clicking one of the sprites, it should calculate the time for the hours and the days while the object circles around the earth!


    Unlock the Full Learning Experience

    Get ready to embark on an incredible learning journey! Get access to this lesson and hundreds more in our Digital Skills Curriculum.

    Copyright Notice
    This lesson is copyright of Coding Ireland. Unauthorised use, copying or distribution is not allowed.

    Scratch is developed by the Lifelong Kindergarten Group at the MIT Media Lab. It is available for free at https://scratch.mit.edu
    🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more