Horses Computer Science Content
This section is a quick overview of definitions we’ve already covered, but these are the
definitions you definitely want to get across to the students before starting the lesson. There
are multiple ways you could introduce these definitions to the students, but we encourage
using examples to drive the definitions in.
Boolean
A boolean (true/false) is a type of variable that can take one of two values:
true or false.
Booleans can be used as the condition in a conditional (if/then) statement or as
a condition (sometimes
called the loop guard) in a while loop. In Alice, functions can return a boolean
variable. For example, the
world has a function “both a and b” that takes as input two booleans, a and b,
and returns true if both are
true, and false if otherwise.
A comment is a region of text in code that is not meant to be executed, but
instead provides
information about the executable code around it.
Conditional Statement
A conditional (if/then) statement controls whether or not certain lines of code
are executed. A boolean (true/false) value or expression is given as input, and
if that value is true, then the
code is executed. For this reason, conditional statements are sometimes referred
to as if/then statements.
In Alice, if/else blocks can be found at the bottom of the programming
environment, all if blocks have an
else block that follows. Code in the else block is executed if the input value
is false. We see conditional
statements in everyday language as well! For example: if the day is
Monday, then we go to school.
Property
A property is a variable that describes an object. In Alice, all objects (e.g.,
horse) have
properties, including skin texture and isShowing. You can see the list of
properties for an object by
clicking on the object in your scene, then select in the properties tab under
objects details in the
bottom left hand corner.
Variable
A variable is a value that stores information to describe an object or method.
The value can be
a number (e.g., height), a string (e.g., name), or even a color. In Alice, for
example, a variable is used when
the user wants to specify the number of jumps an object should take.