Task 1: Create A Storage Calculator in Scratch: Year 8, Unit 2, Lesson 2, Worksheet 1
Task 1: Create A Storage Calculator in Scratch: Year 8, Unit 2, Lesson 2, Worksheet 1
Let’s make a calculator to see how many kibibytes, mebibytes and gibibytes are used for
different files.
The calculator needs to ask the user ‘What is the file size in bytes?’
The calculator will then need to do a division to work out how many KiB are being used to
store the file size entered in bytes.
The calculator will need to use a variable to store the answer of the division.
To work out how many kibibytes are in the file you will need to use the following code:
Use this code to convert bytes to KiB. When you have done this can you make the code to
convert the bytes to MiB and GiB.
What to do:
1) Open Scratch
2) Find the variable blocks.
a. Create a new variable called ‘FileSizeKibibytes’
b. Drag the ‘set FileSizeKibibyte to__’ block onto the working area
c. Drag the ‘show variable FileSizeKibibyte’ block onto the work area.
6) Change the 0 to be 1024 because that is how many bytes are in a kibibyte. Now you
can convert from bytes to kibibytes.
7) Add the variables you will need for gibibytes and mebibytes:
a. FileSizeMebibytes
b. FileSizeKibibytes
Use the following blocks to create the code to change from bytes to mebibytes:
Now you can create the code to change from bytes to gibibytes using new blocks.