3.2 Programming
No description yet. This curated deck is ready for daily study.
Card preview (24)
Data types
Programming languages store data as different types and they are dealt with differently by the program.
INT
Integer - whole numbers, positive and negative
REAL
Numbers that have a decimal point- sometimes called FLOAT
BOOLEAN
Can have one of two values - true/false, yes/no, 1/0
CHAR
Character - a single letter, number or symbol
STRING
Used to represent text - it is a collection of characters
Casting
Changing one data type to another, e.g. converting string to integer
DIV operator
Returns the whole number part of a division, e.g. 5 DIV 2 = 2
MOD operator
Returns the remainder part of a division, e.g. 5 MOD 2 = 1
Assignment
Assigning a value to a variable or constant, e.g. total=25 assigns the value 25 to the variable total
Comparison operator
Compares the left hand side of an expression to the right hand side, e.g. 4<10 (is 4 less than 10)
Same as?
Python uses ==
Not the same as?
Python uses !=
Variable
A named data store which can change as the program is run
Constant
A named data store which cannot be changed as the program is run, e.g. pi
Local variable
A variable that is only defined and usable in certain parts of a program
Global variable
A variable that can be used throughout the whole program
Selection
A decision/way of controlling a program using a selection statement, IF - THEN - ELSE
Nested IF statements
Using an IF statement inside another one.
ELIF
Used where there is more than one option in a selection statement. Short for ELSE - IF
Iteration
A way of repeating a set of instructions - can be a based on a condition or a number of repetitions
FOR LOOP
A count controlled loop
Array
A data structure that can store a group of data values of the same time. A one-dimensional array could be called a LIST. A two-dimensional list could be called a TABLE.
Subroutine
A set of instructions stored under one name which can be used (called) when you want the program to use them