About the Pseudocode Activity.

The Pseudocode Activity allows small programs to be entered with Pseudocode. It uses an input mechanism which restricts the entry so that only valid code can be entered.

The code can then be run using the Trace Table tab to show how the variable values change as the code is run. There is also the option to run the code line by line and to show the flow of the program. The Pseudocode is loosely based on the that used by AQA in its Computer Science exams. This activity can be used to give a better understanding of PseudoCode and as practice for answering the trace table questions in the exam. The activity could be used to help design programs or as a way to start to learn the basic principles of coding.

Name:
Upload Saved Program
Note that this is a testing release. Please contact me is you find any issues.

Variables.

Variable
Type
Value
Options
Code

Select a command


Or use text entry



Code



Trace Table.

Example Programs



Example Programs

There are a number of example programs which can be loaded in from the Variables Tab to illustrate how Pseudo-Code can be written and run using this application.

Power
Calculates the power of the given value of x to the given value of y (x^y). For example: when x = 5 and y = 3, it returns 125 (5 x 5 x 5)
Factorial
Calculates the factorial of the given value (value!). For example: when value = 4, it returns 24 (4 x 3 x 2 x 1)
Logic
Compares a with 2 and b with 5, given the results when both are true (AND), at least one is true (OR) and exactly one is true (XOR).
Prime
Determines if x is prime by using a count to go through all of the values from 2 to the square root of the number, rounded down. If x MOD count is 0, then x cannot be prime and a flag is set. If the flag has not been set, then x is prime.
Tables
Displays the times tables from 1 to MAXA to 1 to MAZB
Search
Does a linear search through a List to find a specific value.
Sort
Does a bubble sort on a list of unsorted values which are randomly generated numbers between 1 and 100.
Fibonacci
Generates the first 10 values is the fibonacci sequence.
Binary to decimal
Takes a binary number represented in a array of 0/1 values and converts it to decimal.
Decimal to binary
Takes a decimal number and generates the binary representation of it.
Two's Complement
Takes a positive/negative binary number represented in Two's Complement format and changes it to the Two's Complement format of the same number but with the sign changed.
Log 2
Calculates the log base 2 of a number rounded down and determins the number of bits required to represent the given number of values.
Calculate e
Used the Maclaurin seried to generate the value of e
Probability
Similates rolling two dice 1000 times to get an approximate probability for throwning two sixes.

Pseudocode Web Activity.

The Pseudocode Activity allows small programs to be entered with Pseudocode. It uses an input mechanism which restricts the entry so that only valid code can be entered. The code can then be run using the Trace Table tab to show how the variable values change as the code is run. There is also the option to run the code line by line and to show the flow of the program. The Pseudocode is loosely based on the that used by AQA in its Computer Science exams. This activity can be used to give a better understanding of PseudoCode and as practice for answering the trace table questions in the exam. The activity could be used to help design programs or as a way to start to learn the basic principles of coding.

Variables Options

A total of ten variables can be created for use in the PseudoCode. They can be one of six different types and can have a value allocated to them. Note that if the value is left empty, a default will be allocated. Details on different types of variables can be found further down the help page.
Set
The set option relating to a variable allows for a new variable to be created
Update
The update option relating to a variable allows the variable name and/or default value to be updated. If the variable name is changed, any code will be updated to reflect the change.
Delete
The delete option relating to a variable allows a variable to be deleted so that a new variable can be created. If the variable is being used by the code, then an error is displayed and the variable will not be deleted.

Code Options

Delete
The delete options deletes all code assosicated with the current line. The code which is to be removed is firstly highlighted in red with the options to confirm or cancel the action.
Clear
The clear option clears the code but does not reset the variables
Reset
The reset option clears the code and variables, resetting the state to that when the page is first displayed with a example output "Hello World" command.
Save
The save option creates a download of the current variables and code with the name based on the name entered on the "Variables" tab and the .pscode extension. The code can then be loaded in using the Load opton on the Variable Tab.

Trace Table Options

Run
The run options runs the whole code and displayed each variable update on a separate line
Output
The output option runs the whole code and but only displays the output.
Trace/Step
The trace option runs the code line by line. Click on the "Step" button for the next line
Flow/Code
The flow option toggles between displaying the whole code and displaying the code with line numbers and relevant goto values

Variable Types

String
A string allows for text input. Strings can be compared to text and be assigned to other string variables or text with the option of including any variable value. The default value is the empty string.
Integers
An integer allows positive and negative whole numbers to be used. They can be used in comparison statements and have the following arithmetic operations performed on them: addition (+), subtraction (-), multiplication (x), modulus (MOD - the remainder when integers are divided by each other) and integer division (DIV). They can also be assigned to the results of the LENGTH, RANDOM, ROUND and FLOOR functions.The default value is 0.
Float
A float allows numbers with a fractional part, displayed after the decimal point, to be used. They can be used in comparison statements and have the following arithmetic operations performed on them: addition (+), subtraction (-), multiplication (x) and division. They can also be assigned to the results of the LENGTH, SQRT, RANDOM, ROUND and FLOOR functions.The default value is 0.
Count
A count is used within a FOR statement and can be used as an integer. It is assigned to the firs value in the FOR statement and increased until it exceed the final value. It can be used within an assignment but it's value cannot be changed. Without a count variable, the FOR statement cannot be used. The default value is 0.
Boolean
A boolean can only take the values true and false. It can be used in comparisons statements and have its value updated. It's default value is true.
Integer Array
The array represents an array of integers. Either the value can be set to a whole positive number which represents the size. The values will then default to 0s. Alternative the array can be entered with spaces between each value. If an entry is not an integer, it is set to 0. The default value is "1 2 3", an array of three values.
String Array
The array represents an array of strings. The default value is "A B C D E F", an array of six values.

Commands

The commands are context specific. Some commands, for example the OUTPUT command, do not require any variables to have been defined before they can be used. Others are greyed out until they are in the correct state to be used. Additional input is also context specific and variable values, operators and value entry is only presented at the relevant point when entering a command.

Commands can be removed mid entry by using the delete option, and then re-entered, but it is currently not possible to edit a command.
LET
The LET command allows a value, variable or the result of an operation on two of these to be assigned to a variable. Once this variable value has been entered the LET keyword is removed from the code.
IF
The IF command Starts a conditional statement with one or two conditions. For two statements the result is true bepending of the logical operator: AND requires both statements to be true, OR requires at least one statement to be truef and XOR requires exactly one statement to be true.
ELSE
The ELSE command can only be entered before an ENDIF command. It is used for the code which if run when the preceding IF and ELSEIF statements are false.
ELSEIF
The ELSEIF command can only be entered before an ELSE or ENDIF command, or before another ELSEIF command. It is used for the code which if run when the preceding IF and ELSEIF statements are false.
WHILE
The WHILE command creates a loop which keeps running while the current condition is true. If the condition is immediately false, the code in the loop will never be run.
REPEAT
The REPEAT command creates a loop which keeps running while the UNTIL condition is true. The code will always run once before the condition is checked.
FOR
The FOR command can only be entered if a count type variable has been created. The count variable is set to the first value. At the end of each loop the count variable is increased by one. The loop keeps repeating until the the count variable exceeds the last value.
BREAK
The BREAK command causes the code to break out of a loop. For this reason, the Break command is only available at the end of a conditional statement within a loop.
OUTPUT
The OUTPUT command can take up to two string values each followed by a variable. The contents is displayed in the output column of the trace table
COMMENT
The COMMENT command allows text to be entered to explain how the program works. It is ignores within the trace table.
SHOWALL
The SHOWALL commands allows all of the variables with the show flag set to be displayed in a row within the trace table.
BREAKPOINT
The BREAKPOINT commands caused the code to stop running at that line until the "continue" button is pressed.

Functions

Functions can be used in the LET statement. The take a single arugument as a value or variable, and return an integer or a float.
LENGTH
Takes an array value and returns the number of items in the array, or takes a string value and returns the length of the string.
SQRT
Takes an integer or a float and returns the positive square root of the value.
RANDOM
Takes an integer and returns a random integer value between 1 and the given value.
ROUND
Takes a float and rounds it to the nearest integer.
FLOOR
Takes a float and rounds it down to the highest integer which is equal or less than the given value.