2.2 New Flashcards
variable
a named memory location that holds data that during the execution of a program, the data can change
what can variables store
different data types such as numbers, text or true/false values
how to store data in a variable
process of assignment
constant
fixed data that during the execution of a program cannot change
what can a constant store
variety of different types of data
assignment
process of storing data in a variable or constant under a descriptive name
how to assign a value to a constant in OCR reference language
const pi = 3.141
operator
symbol used to instruct computer to perform a specific operation on one or more values
examples of common operators
arithmetic
comparison
Boolean (and, or and not)
input
a value that is read from an input device and then processed by a computer program
output
value sent to an output device from a computer program
programming construct
determines the order in which lines of code are executed
three programming constructs
sequence
selection
iteration
sequence
-refers to lines of code which are run one line at a time
-lines of code are run in they order that they are written from the first line of code to the last line of code
selection
-when the flow of a program is changed, depending on a set of conditions
-the outcome of this condition determines which lines or blocks of code is run next
ways to write selection statements
if/then/else
case select or switch
what is selection used for
validation, calculation and making sense of a user’s choices
difference between if and select case
-select case can mean less code but is only useful when comparing multiple values of the same variable
-if statements can be more flexible and are generally used more in languages such as Python
iteration
repeating a line or a block of code using a loop
two types of iteration
count controlled
condition controlled
count controlled
when the code is repeated a fixed number of times
condition controlled
when the code is repeated until a condition is met
data type
-a classification of data into groups according to the kind of data they represent
-computers use different data types to represent different types of data in a program
what are the data types
-integer
-real
-character
-string
-boolean
integer
whole numbers
real
numbers with a fractional part
character
single character
string
sequence of characters
boolean
true or false values
importance of choosing the correct data type for a given situation
ensure accuracy and efficiency in the program