Programming Y10 Assessment Flashcards
Describe what is meant by ‘data type’
The data type determines what type of value the variable will hold.
Define ‘integer’, ‘real’, ‘Boolean’, ‘character’ and ‘string’ data types
INT - 2/4 bytes - whole number,
REAL - 4/8 bytes - decimal numbers,
BOOL - 1 bit needed but 1 byte usually used - TRUE/FALSE,
CHAR - 1 byte - a single alphanumerical character
STRING - 1 byte per character - One or more alphanumeric characters
Declare and assign constants and variables
Constant) CONSTANT PRESSURE
Describe ‘iteration’
There are times when a program needs to repeat certain steps until told otherwise, or until a condition has been met. This process is known as iteration
Describe ‘Selection’ + example with multiple selections
Selection is a programming construct where a section of code is run only if a condition is met.
IF \_\_ THEN OUTPUT ‘_’ ELSE IF _ THEN OUTPUT ‘_’ ELSE OUTPUT ‘_’ ENDIF
Use and explain definite (count-controlled) iteration
When a program needs to iterate a set number of times, this is known as definite iteration and makes use of a FOR loop.
FOR k
Use and explain indefinite (condition-controlled) iteration:
• Indefinite iteration repeatedly executes a section of code until a condition is met - or no longer met. There are two types of indefinite iteration:
• WHILE loops - uses the statements WHILE and ENDWHILE
WHILE total < cost
coinValue
Use and explain nested structure
Including one programming construct within another.
• FOR x ← 1 TO 10
FOR y ← 1 TO 10
result ← y * x
OUTPUT y + “ * “ + x + “ = “ + result
ENDFOR
ENDFOR
Explain the need for meaningful identifiers
Making sure you use variable names that describe what the variable contains is very important. Poor variable names can make it difficult to work out what is going on in your program
Write code that accepts keyboard input
name ← USERINPUT
Write code to display output on a screen
OUTPUT “Hello” + name
Write code to perform string operations ‘length’, ‘position’, ‘substring’ and ‘concatenation’
- LEN(string)
* POSITION(string, character)
* SUBSTRING(x, y, string)
* Concatenation - multiple strings joined together : newString
Write code to cast one data type as another
- STRING_TO_INT(‘1)
* STRING_TO_REAL(‘1.0’)
* INT_TO_STRING(1)
* REAL_TO_STRING(1.0)
* INTs and REALs have quote marks, strings don’t!• CHAR_TO_CODE(‘b’)
Write code that performs arithmetic operations (addition, subtraction, division, multiplication)
- +
* -
* *
* /
Write code that performs relational operations (combinations of less than, equal to, not equal to and greater than)
- =
* ≠
* <
* >
* ≤
* ≥