You are on page 1of 3

Vocabulary

Statement Instruction to be executed. Think Command in command prompt. Python 3.x Example: print ('Hello, world!') Output: Hello, world! Comment Part of a code that is ignored by the program during execution. Used to add notes in the code. Python 3.x Example: #This is a comment XHTML example <!--This is a comment--> In my pseudocode Ill be using two forward slashes for comments, as in: //This is a comment in my pseudocode Identifier A name assigned to a variable or subroutine. Most languages have rules as to what you can assign as an identifier. In Python 3.x, identifiers must start with either a letter or an _ (underscore), and can contain any number of letters, underscores and numbers. Variable Constant Reserved Word Data type An item used for data storage. A variable that is not to be altered during the execution of a program. A keyword that cannot be assigned as an identifier due to its special use in a language. Reserved words depend on language. The type of a piece of data. Most common are String, Integer and Boolean. Python 3.x Example: type('Hello, world!') Output: <class 'str'> type(1337) Output: <class 'int'> type(True) Output: <class 'bool'> Selection Construct

//That is a string

//That is an integer

//That is Boolean

Used to allow a program to execute one of different pieces of code based on whether a condition is true. Most common are the If-Then-Else construct and the Switch statement (no major difference between the two.) Used for repetition of code; also known as a loop. One repetition of the code is known as an iteration. Most common types of loops: While Loop Do While/Repeat Until Loop For Loop

Iteration/ Repetition Construct

Subroutine A self-contained piece of code, i.e. only executed when called by another part of the code. Used when the same block of code needs to be used in different parts of the program so it is not necessary to take up space by writing the same code again, but instead just calling it whenever it is needed. Procedure Function A subroutine that, unlike a function, does not return a value. A subroutine that returns a value after execution. Think f(x) in mathematics. The function is defined, and then one can enter a value into the function to receive a result. Often used interchangeably with procedure. Maths example: f(x) = x*3 f(3) = 9 Pseudocode example: Function f(x) result = number*3 Return result End Function number User Input print f(number) //f is just an identifier. It could be anything. //This assigns a value to variable result //Returns a value, unlike a procedure //Signifies the end of the function // indicates input //Calls the function and prints the return value (result)

If we assume user input is 3 (x 3), output will be 9.

More on data types


In each language, there can be dozens of different data types, and in many it is possible to create custom data types. It would be extremely pointless to go over every data type so I will go over the most basic. Most other data types are composites of these ones. Type name Byte Char Boolean Description 8-bit integer Single ASCII or Unicode Character Binary Data Range/Example -127 to +127 or 0 to 255 A or G or 5 True or False

In most languages Boolean is represented as True/False. In lower levels it can be represented as 1 or 0, where 1 is True and 0 is False. In higher levels in can be used for specific cases (Wikipedia extract): the outcome of an experiment ("success" or "failure") the response to a yes-no question ("yes" or "no") presence or absence of some feature ("is present" or "is not present")

Common composite data types can include: Type name Description Integer 32-bit integer (usually)

Long Float Double String

64-bit integer (usually) 32-bit decimal (usually) 64-bit decimal (usually) Sequence of Characters

Range/Example -2,147,483,647 to +2,147,483,647 or 0 to 4294967295 You get the memo 0.00001 or 35.12254 You get this memo too Hello, world! or asdf123

Sources
http://en.wikipedia.org/wiki/Control_flow http://en.wikipedia.org/wiki/Iteration http://en.wikipedia.org/wiki/Binary_data http://www.ashishpaliwal.com/blog/2009/08/if-else-vs-switch-%E2%80%93-which-is-better/ http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html http://www.amazon.com/Cambridge-International-Computing-Coursebook-Examinations/dp/0521186625