ClassVIII Coding Project Booklet
ClassVIII Coding Project Booklet
CODING CURRICULUM
GRADE VIII
Volume 1.0
TABLE OF CONTENTS
DISPLAYING IF A NUMBER IS ODD OR EVEN USING MINECRAFT .........................1
THE NESTED DIVISION PROBLEM ...................................................................7
CAT RAIN .....................................................................................................9
CREATE A STAIRCASE USING FOR LOOP ........................................................ 13
CREATE A STAIRCASE USING WHILE LOOP .................................................... 16
RAINING PIGS AND PANDAS.......................................................................... 19
CALCULATING VOLUME OF CUBOID.............................................................. 22
FUN IN MINECRAFT USING ARRAYS ............................................................... 27
BUILDING STAIRS USING ARRAYS ................................................................. 30
PRINT NUMBER DIVISIBLE BY 3 BETWEEN 1 AND 100 ..................................... 33
PRINT THE REVERSE OF AN INTEGER NUMBER .............................................. 35
BUBBLE SORT ............................................................................................ 39
SECOND HIGHEST INTEGER IN AN ARRAY OF N INTEGERS .............................. 43
REFERENCES ............................................................................................. 49
I
Odd or even using Minecraft
Solution: You should try this exercise on the Minecraft Education Edition. You may
set up the Minecraft education edition from https://education.minecraft.net/get-
started.
At the end of this activity, you can expect following output on screen:
1|Pag e
Odd or even using Minecraft
2|Pag e
Odd or even using Minecraft
3|Pag e
Odd or even using Minecraft
4|Pag e
Odd or even using Minecraft
Now we will implement the example of odd-even to display some messages on the
screen.
The program that you have written assigns 34 to a variable named as a. Then, in the
next lines of code, it checks whether variable a is now divisible by 2. If it is divisible,
we are displaying a message on the screen. At line 3, 5 and 6 the statement player.say
is used for displaying the message in the screen.
When you are done with typing the necessary lines of code, click on the green Start
button to execute the program. You will see the below result displaying number is
even.
5|Pag e
Odd or even using Minecraft
6|Pag e
Nested Division
Solution: To do this, open Minecraft Code Editor again. You can get the instructions
from previous sections for doing that.
Now that you have Minecraft Code Editor opened, type down the program as given
below. Make sure the indentations are correct.
7|Pag e
Nested Division
After you are done with typing the code, click on the green Start button to execute the
program.
Result:
You will now see that message is displayed according to the logic we have written in
our program. It assigns 44 in a variable called number. Then it goes through our
nested if-elif blocks to display the result. If you have typed the lines of code properly,
clicking on Start button will display a message like below.
Now press C key to go back in the code editor. You can change the value of the
variable and run it again. By doing that, you can verify if the program is behaving as
you have expected.
8|Pag e
Cat Rain
CAT RAIN
Chapter: Get Creative With Loops.
Solution: To do this, open Minecraft Code Editor again. You can get the instructions
from previous sections for doing that.
Below is how the exercise will look when implemented with block coding with
Minecraft
The final output of this exercise should look like as shown in the image below.
9|Pag e
Cat Rain
However, in this exercise, we will try to implement the same code using python.
10 | P a g e
Cat Rain
Follow the below code block. We have used a for loop with range 100 – This means
that the loop will run 100 times.
So, the line mobs.spawn(CAT, pos(0, 10, 0)) will be executed 100 times.
11 | P a g e
Cat Rain
After you click on play 100 cats will rain from the sky.
12 | P a g e
Staircase Using for Loop
To create a block of stairs with for loops using Minecraft coding platform.
Problem Statement: When a block of stairs is created,two things needs to be
considered. First is the number of stairs present in the block of stairs. Second is that
each staircase should be of identical dimension. This activity of building a block of
stairs can be done using a computer program in Minecraft. Can you write a program
in Minecraft to build a block of stairs using for loop.
Learning Outcome: At the end of this exercise, you will learn:
• How to use FOR loop within a program in Minecraft tobuild block of stairs.
Solution: To do this, open Minecraft Code Editor again. You can get the instructions
from previous sections for doing that.
Below is how the code will look when implemented with block code using Minecraft
education edition.
At the end of this exercise, the final output should look like shown in the below image.
13 | P a g e
Staircase Using for Loop
14 | P a g e
Staircase Using for Loop
So, we see how the same action is performed using a for loop. The detailed explanation
of the previous code is given below:
Step 1: Teleporting the builder to the specified position
Step 2: Creating a for loop which will run 10 times
Step 3: Inside the for loop we will move the builder forward by 2 steps
Step 4: Move the builder up by 1
Step 5: Finally the builder traces the path travelled and puts a block on the position
Step 6: Click on play. You will see a flight of stairs of height 10 and having width of 3
blocks.
15 | P a g e
Staircase Using for Loop
To create a block of stairs with while loops using Minecraft coding platform.
Problem Statement: When a block of stairs is created,two things needs to be
considered. First is the number of stairs present in the block of stairs. Second is that
each staircase should be of identical dimension. This activity of building a block of
stairs can be done using a computer program in Minecraft. Can you write a program
in Minecraft to build a block of stairs using while loop.
Learning Outcome: At the end of this exercise, you will learn:
• How to use WHILE loop within a program in Minecraft tobuild block of stairs.
Solution: To do this, open Minecraft Code Editor again. You can get the instructions
from previous sections for doing that.
Below is how the code will look when implemented with block code using Minecraft
education edition.
16 | P a g e
Staircase Using for Loop
At the end of this activity, the final output should look like shown in the image below.
17 | P a g e
Staircase Using for Loop
Step 7: Finally, the builder traces the path travelled and puts a block on the position
Step 8: Finally run the code by clicking on play then on the chat window type step 10
Results: You will see a stair of height 10 formed in your Minecraft world
18 | P a g e
Staircase Using for Loop
To create raining Pigs and Pandas with while loop using Minecraft coding platform.
Problem Statement: When you use the term “Raining cats and dogs”, you mean to
say that it is raining unbelievably hard. Similar concept can be replicated in a
computer program, by raining pigs and pandas from the sky in Minecraft. Can you
write a program in Minecraft to rain pigs and pandas from the sky using while loop?
Learning Outcome: At the end of this exercise, you will learn:
Solution: To do this, open Minecraft Code Editor again. You can get the instructions
from previous sections for doing that.
Below is how the code will look when implemented with block code using Minecraft
education edition.
And when done with Python, the code will look like below.
19 | P a g e
Staircase Using for Loop
At the end of this activity, the final output on screen should look like shown in the
image below.
20 | P a g e
Staircase Using for Loop
Step 2: Now start a while loop which will run till the value of “animals” variable is less
than or equal to 100.
Step 5: Lastly, update the value of variable “animals” to “animals = animals + 1”.
Step 6: Finally run the code by clicking on play then on the chat window type rain
100
Result: After you run the code you will see 100 pigs and 100 pandas dropping from
the sky in your Minecraft Environment
21 | P a g e
Staircase Using for Loop
Problem Statement: In mathematics, you have learned about finding the volume of a
cuboid with dimensions L, B & H. This can be done using a computer program also.
Consider you have been given a cuboid with dimensions L, B & H. You need to
determine the volume of the cuboid using a function within a computer program. Can
you write a program for the same using python in Minecraft?
Learning Outcome: At the end of this exercise, you will learn:
Solution: To do this, open Minecraft Code Editor again. You can get the instructions
from previous sections for doing that.
At the end of this exercise, the final output should look like shown in the screen
below:
Let us now try to replicate this output on our screen by following the steps below:
22 | P a g e
Staircase Using for Loop
23 | P a g e
Staircase Using for Loop
24 | P a g e
Staircase Using for Loop
25 | P a g e
Staircase Using for Loop
26 | P a g e
Staircase Using for Loop
To create an array of flowers and calculate the length of the array to create a flight of
stairs. using Minecraft coding platform.
Problem Statement: Consider you have been asked to create an array which contains
the name of different flowers. You then need to calculate the length of this array. Once
you have the length of the array, you need to create a set of stairs having the same
length as the array.Can you write a program same using python in Minecraft to
implement the above steps?
Learning outcome: At the end of this exercise, you will learn:
Solution: To do this, open Minecraft Code Editor again. You can get the instructions
from previous sections for doing that.
At the end of this exercise, the final output on the screen should look like as shown in
the below screenshot.
27 | P a g e
Staircase Using for Loop
In this activity we will create an array of flowers and calculate the length of the array
to create a flight of stairs.
28 | P a g e
Staircase Using for Loop
Step 3: Create a variable called length which is the length of the array flower
Step 4: Start a for loop which will run as many times as the length of the array
Step 6: Finally, the builder traces the path travelled and puts a block on the position
Step 7: When you hit play you will that there is a golden stair created.
29 | P a g e
Staircase Using for Loop
To build a flight of stairs using the material present in the 1 st position of the array.
using Minecraft coding platform.
Problem Statement: Consider you have been given an array which contains the
names of different materials. You then need to calculate the length of this array and
determine the material at the first position of the array. Once you have the length of
the array and the name of the material at the first position of the array, you need to
create a set of stairs having the same length as the array, with the material at the first
position of the array.Can you write a program same using python in Minecraft to
implement the above steps?
Solution: To do this, open Minecraft Code Editor again. You can get the instructions
from previous sections for doing that.
At the end of this activity, the final output should look like shown in the image below:
30 | P a g e
Staircase Using for Loop
Below is how the python code will look in Minecraft education edition.
31 | P a g e
Staircase Using for Loop
Step 4: Starting a for loop which will run as many times as the length of the array
Step 5: Moving the builder forward by 1 step and then up by 1 step
Step 6: Finally, the builder traces the path travelled and puts a block of material
present on the 1 st position (Chiseled Sandstone) in the array material on the traced
path
Step 7: When you hit play you will that there is a Sandstone stair created.
32 | P a g e
Numbers divisible by 3
between1 and 100
Problem Statement: Suppose, you have been given natural numbers from 1 to 100.
You need to write a program to find and print the numbers divisible by 3 between 1
and 100 using the Minecraft coding platform.
Solution: To do this, open Minecraft Code Editor again. You can get the instructions
from previous sections for doing that.
At the end of this activity the final output should look like shown in the image below:
Let us start to replicate this activity to Iterate a loop from 0 to 100 as shown below
33 | P a g e
Numbers divisible by 3
between1 and 100
34 | P a g e
Find reverse of an integer
To print the reverse of an integer number.(e.g. For a given numer say 12345, print the
reverse i.e 54321)
Problem Statement: You have been given an integer number, say N. You need to
write a program to print an integer number where the digits are in reverse order
compared to the original integer. This needs to be done using the arcade coding
platform.
Learning Outcome: At the end of this exercise, you will learn:
• How to play around with an integer to find the reverse of the same.
• How to use modulus operator.
• Advanced usage of looping concept.
Solution: To do this, open the arcade code editor using the following URL:
https://arcade.makecode.com/
35 | P a g e
Find reverse of an integer
36 | P a g e
Find reverse of an integer
37 | P a g e
Find reverse of an integer
38 | P a g e
Bubble Sort
BUBBLE SORT
Chapter: Get Creative With Loops & Programming With Arrays.
This activity will help you to sort a set of random numbers present in an array either
in ascending or descending order.
• How to sort a given set of numbers in ascending order using bubble sort.
• Extend the concept learned here to sort a given set of numbers in descending
order using bubble sort.
• The maximum count of value swapping possible to sort a given set of n
numbers.
Solution: Let us consider a set of numbers 1, 5, 4, 3, 2; that needs to be sorted in
ascending order. Here, we will be using a robot which cannot see so well. It can pick
one number in its left hand, and the other number in its right hand, take them close
to its eyes to read the numbers. If the number on the left is greater than the number
on the right, it swaps the two numbers. This is done until the numbers are sorted in
ascending order.
1 5 4 3 2
• Then we compare the numbers 5 and 4
• Since 5 is greater than 4, we will swap these two numbers.
1 5 4 3 2
39 | P a g e
Bubble Sort
1 4 5 3 2
• Lastly, we compare 5 and 2
• Since 5 is greater than 2, we will swap these two numbers
1 4 3 5 2
• The list of the numbers is rearranged as follows:
• Notice 5 is the largest number in this list and arranged at the last position.
1 4 3 2 5
• We again start from the beginning and compare 1 with 4. Since 4 is greater
than 1, no change is made.
1 4 3 2 5
40 | P a g e
Bubble Sort
1 4 3 2 5
1 3 4 2 5
• Lastly, we compare 4 and 5. Since, 5 is greater than 4, no change is made.
1 3 2 4 5
• We again start from the beginning and compare 1 with 3. Since 3 is greater
than 1, no change is made.
1 3 2 4 5
41 | P a g e
Bubble Sort
1 3 2 4 5
• Next, we compare the numbers 3 and 4. Since 4 is greater than 3, no change is
made.
1 2 3 4 5
• We again start from the beginning and compare 1 with 2. Since 2 is greater
than 1, no change is made.
1 2 3 4 5
1 2 3 4 5
42 | P a g e
Second highest integer in
an array of N integers
Problem Statement: Suppose you have been given an array of N integers. We need to
write a program to find out and print the second highest integer in the array if it
exists. This needs to be done using the arcade coding platform.
• How to play around with arrays to find the second highest integer.
• Advanced usage of loops.
• Application of IF-ELSE IF-ELSE in programming.
• This exercise relates to the concepts that we learnt in Chapter 2 – Get Creative
With Loops & in Chapter 4 – Programming With Arrays.
Solution: To do this, open the arcade code editor using the following URL:
https://arcade.makecode.com/
43 | P a g e
Second highest integer in
an array of N integers
44 | P a g e
Second highest integer in
an array of N integers
45 | P a g e
Second highest integer in
an array of N integers
46 | P a g e
Second highest integer in
an array of N integers
47 | P a g e
Second highest integer in
an array of N integers
48 | P a g e
References
REFERENCES
Microsoft. 2021. Microsoft MakeCode Arcade. [Online]. [16 March 2021].
Available from: https://arcade.makecode.com
Microsoft. 2021. Minecraft MakeCode | Rain cats and dogs. [Online]. [16 March 2021].
Available from: https://minecraft.makecode.com/examples/cats-vs-dogs
49 | P a g e