What is pseudocode anyway? We'll talk about that in this lesson!
The questions on the computer science certification test
that use programming language code segments as a basis
use a type of language called pseudocode,
which literally means "false code".
It doesn't really work, but is suitable
for representing code examples on the test,
and looks a lot like several current languages that do work.
A copy of this pseudocode reference page
will be available to view on the computer during the test,
in case you need to look at it.
This three-part video series will go through
all the aspects of the pseudocode system.
It can be found in the preparation manual.
We will explore all aspects of this system
so that you can better understand what is going on with it.
During this series, we will also refer to the
WeTeach_CS Pseudocode reference pages.
More specific examples are shown,
and you are encouraged to look that over for extended study.
Let's start at the top.
The format of this system, as you see, is shown in two columns,
with the Explanation in the left column,
and the actual Notation used in the right column.
It starts with operators you can expect
to see in code examples on the test.
The first symbol shown is the assignment operator,
which in many languages is the "=" sign,
but in this system, is the left arrow symbol.
This is a binary operator,
which simply means it takes two operands,
or "things" it works with, one thing on the left,
and a thing on the right.
The item on the left is an identifier
for a memory container of some sort,
like a variable, constant or object reference.
The operator is simply taking the "thing" or value on the right,
and dumping it into, or assigning it to, the container on the left.
It is a right to left action, which is very important to understand.
On the next line, you can see
six different operators that are math related,
and work just as they do in math.
The first four are the standard math operations of
addition, subtraction, division and multiplication.
Typical math operations can be defined using literal values,
ones you can actually see in the code, or variables,
memory containers which have been assigned previous values.
The caret symbol is what will indicate a power, like 2 caret 3,
which means 2 to the power of 3,
resulting in the value 2 times 2 times 2, or 8.
The last operator is the modulus, or "mod" for short,
which simply performs a division operation,
but takes the remainder value as the answer.
For example, 10 mod 6 has a resulting answer of 4,
since 4 is the remainder after dividing 10 by 6.
If you do 6 mod 10, the mod answer is 6. Think about it.
On the next line are the relational operators,
which are used to compare two values at a time,
again just as they are used in math expressions.
The result of each of these is a boolean value, or true/false.
It is either true or false that two values are equal to each other,
or one less than the other, or one greater than or equal to the other,
and so on.
The logical operators that will be used on the test
include AND, OR, and NOT,
and in code examples will be expressed using these actual words.
For the AND conjunction operator to be true,
both expressions must be true,
otherwise the resulting boolean value is false.
The OR operator is true when either expression,
or both, are true.
It is only false when both expressions are false.
The NOT operator only works on one expression,
located in front of it,
and simply reverses its state from true to false,
or false to true.
Now we see something that might seem familiar,
but is possibly not.
The plus sign normally is associated with addition,
but in this case it has a different function called "concatenation",
which simply means "connecting" two string values
into one complete string value.
The rule for this operator is that at least one of the two operands
on either the left or the right side must be a string.
The other can be any other type of data, including numeric values.
Next we see the two Boolean values we have been discussing already
true and false.
In most modern languages, these words are actually used
and recognized by the compiler as true and false,
and are NOT considered words or what we call strings.
The word "null" literally means "nothing".
It is used in many languages to represent the default value
for object reference variables that have not yet been assigned
an object to point to, but must point to something at all times.
Instead, they are assigned the value "null",
which means they are pointing to "nothing".
The use of comments is a form of internal documentation,
which has two forms: single line comments and block comments.
Single line comments begin with two forward slashes.
Using this at the beginning of a line literally "hides" the entire line
from the compiler during the compile process,
but can still be seen by the human eye.
Block comments are indicated using a pair of symbol combinations.
The first combination is the "slash-star"
which starts the comment block,
and the second one is the "star-slash"
which ends the comment block.
This technique can be used to block out
several lines of code at a time,
either to hide them from the compiler
in the debugging process,
or to contain paragraphs of comments,
explaining in greater detail
a section of code as another method of internal documentation.
This is the end of the first of the three-part video lesson series
on the pseudocode system that will be used on the certification test.
Now proceed to the second video in the series.
Không có nhận xét nào:
Đăng nhận xét