Back to Contents Page Lesson 3 Exercise

Lesson 3: Building structures using iterations


Instructions: Complete the tasks below, if you finished early or you find this too easy, try to complete challenging tasks. Also, make sure you save the code after you completed the tasks.


Task 1.0 – Building your name in Minecraft

(3 marks)

Using the built in functions that you have learnt from the last tutorial lesson to build your own name using blocks.


There’s a quicker and more efficient way than building a block at a time.


Here’s an example:




Code in Python


1 for y in Range(0, 4):

2    if y == 0 or y == 4:

3         for x in Range(0, 2):

4              mc.setBlock(x, y, 1, stone)

5         else:

6              mc.setBlock(1, y, 1, stone)


This piece of code above creates the orange blocks and blue blocks shown in the picture above separately, by iterating through the x and y coordinates using different conditions. If y = 0 or y = 4 it creates 3 blocks (orange) in that row, otherwise create a single block (blue) where x = 1.








Task 1.1 – Building Basic Shapes and Structures

Instructions: Build the following shapes and structures using the functions from the API that you have learnt from the last lesson. When you’re building a structure, make sure you build it in an area where it is free, so that you can clearly see the structure after completing each task.


a)    Build a 30 x 20 x 25 cuboid:












(2 marks)


b)    Build a triangle (base = 7 blocks, height = 4 blocks):










(4 marks)

c)     Build a house structure showing in the blueprint below:














(5 marks)




Task 2.0 – Building with your Creativity & Imagination

Instructions: Your task now is to extend the design of the house that you have created in the previous task and adding different structures with your creativity and imagination. If you are connected to a local network, you can complete this task as a class, but you must produce your own code. However, to get marks in the code you must include the following:


_      While loop

_      For loop

_      mc.player.getPos()

_      position.x

_      position.y

_      position.z

_      mc.setBlock(x, y, z, type)


If you’re not sure, here are some words that might inspire you:

_      Flower

_      Water

_      Trees

_      Lava

_      Glass

_      Air

 (6 marks)