A variable is a box or container to hold a value. You can put a different value in a box everytime.
Variables have names. Programs can use variables names instead of raw integers and strings which is very handy. E.g., in the program below, the variable with the name positionX has the integer value 10 and the variable with name message has the value "Hi Brooks School"
positionX = 10
message = "Hi Brooks School"
In the next few tasks, you will practice using variables.
Start Minecraft and run the program cell below before you begin your tasks.
In [ ]:
import sys
sys.path.append('/home/pi/minecraft-programming')
import mcpi.block as block
import time
import drawings
In [ ]:
# Task 1 program
userName="blah"
mc.postToChat(userName)
drawings.drawMyCircle(radius, blockToUse)
Well done!
In [ ]:
# Task 2 program
drawings.drawMyCircle(radius, blockToUse)
The picture above shows the solid shapes studied by the mathematicians Plato and Euclid.
We will use the function drawings.drawSolid to build these solids. This function takes the arguments
drawings.drawSolid(shape,length,blockId)
# e.g., drawings.drawSolid("TETRAHEDRON",5,block.STONE.id)
In [ ]:
# Task 3 program
drawings.drawSolid(shape, length, blockToUse)
Well done!
In [ ]:
# Task 4 program
drawings.drawSolid(shape, length, blockToUse)