< Back

Lab 3: Variables

Variables allow us to store values long term in our program. One of the major uses for them today will be reducing the effort of typing values in our code. But they also aid with readability of a program, and can be very useful in computing values. But we won't see that latter one until Thursday.

For all of our activities, make sure your practice with the new blocks today. Some of the activities you can complete without using the new blocks. They do save some time and headaches. Open up the Practice Area, and take a crack at the following activities.


Activity 1: More Squares!

Create a blockly program which uses variables x, y, and side_length. Your program should use those variables to draw a square centered at the location specified as the value of the variables x and y.

Example 1

x = 150, y = -200, side_length = 50

x = 50, y = 50, side_length = 100


Activity 2: Hexagram

Create a blockly program which will be able to draw a blue hexagram roughly centered in the turtle drawing area. A hexagram can be created by drawing two overlapping triangles. You should try to position the triangles so your hexagram looks as symmetrical as possible.


Activity 3: Triangular Prisim

Create a blockly program which will be able to draw a triangular prisim roughly centered in the turtle drawing area. Each line drawn should be the same length. You can create a triangular prisim by drawing two triangles offset from one another, and connecting the corresponding vertices with lines.