2.2 Programming Fundamentals Flashcards
Define integer
Whole numbers. The integer can be positive or negative and include zero.
Define real/ float
Numbers that have a decimal point. Again – a real number can be negative e.g. -1.8
Define Boolean
Can only take one of two values: true or false, yes or no, 0 or 1
Define character
A single letter, number or symbol, e.g. six, Y, &
Define string
Are used to represent text. It is a collection of characters, e.g. hello
Define casting
Casting is used to change the date type e.g. you can change the integer 7 to string “7”
Define arithmetic operators
Arithmetic operators, take two values and perform a mathematical function on them e.g 5 + 6
Define exponentiation
Exponentiation is used to raise a number to a power. In python the symbols ^ or ** is used
Define DIV
The DIV operator returns the whole number part of a division. In python the symbol // is used e.g 20 // 3 = 6
Define MOD
The MOD operator returns the remainder part of the division. In python the symbol % is used, e.g. 20 % 3 = 2
Define assignment
The assignment operator is used to allocate values to constants or variables.
Define comparison operators
Comparison operators compare the expression on the left-hand side with the expression on the right hand side, and produce a Boolean value, true or false
Define constant
A constant is assigned a data value that cannot be changed as the program runs. E.g. VAT = 0.2. This can then be used in calculations cost = price*VAT
Define variable
The variable is the location of memory that holds one more values. It has a label or name to identify it and its values can be changed as the program runs.
Define string manipulation
The characters in a string are usually numbered starting at zero. You can use commands which give you information about the string or allows you to alter the string.
Define selection statements (IF)
If statements allow you to check if a statement is true or false and then carry out different actions depending on the outcome.
Define selection statements (SWITCH)
Switch statements (also known as case select statements) can check if a variable has a specific value.
Define count controlled loop (FOR)
For loops will repeat the code in them a fixed number of times.
Define condition controlled loop (WHILE)
While loops are controlled by condition at the start of the loop. They will keep going while the condition is true.
Define condition controlled loop (DO)
I do… Until loop is controlled by a condition at the end of the loop. It will keep going until the condition is true. This loop will always run the loop at least once
Define Boolean operators
You need to know three Boolean operators: AND, OR, NOT.
These are used in selection and iteration statements.
Define random numbers
Most programming languages have a function to generate random numbers. These are useful for simple games.
Define arrays
An array is a data structure that can store a collection of data values all under one name. Each value is called an element.
Define two dimensional arrays
Two dimensional arrays can be thought of as a one-dimensional array where each element is a one-dimensional array.