3.2 Programming Flashcards
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
Functions
Subroutines that return a value
Procedures
Subroutines which do not return a value
Structured programming
Breaking down a complex problem into more manageable sub-problems and using subroutines for these.
Robust programming
This protects against unexpected inputs or actions, ensures that users are allowed to enter data and tests for bugs/problems
Authentication
Used to confirm the identity of the user and includes passwords
Validation
revents the accidental or intentional misuse of a program when entering data, e.g. the use of range, presence, format checks, lookup tables and length checks
Testing
Allows the writer of the program to check for syntax and logic errors
Algorithm efficiency
Different algorithms can perform the same taks. The efficiency is less about the lines of code and more about, for example, the number of times a loop was executed or memory accessed.
Trace tables
Allows you to test that a piece of code is working correctly by tracking the values that certain variables take as you go through the code.
High level computer language
Easy for humans to write, e.g. Python
Low level computer language
Easy for computers to run, e.g. machine code and assembly language
Translators
Necessary to translate high level languages into machine code. There are 3 types of translator - assemblers, compilers and interpreters
Machine code
The lowest level language consisting of 1s and 0s
Compilers
Translate all the code at the same time. Can take a long time to compile but once compiled runs the program quickly
Interpreters
Translates and runs the source code one line at a time. This has to be done every time you run the program and runs more slowly
Assemblers
Turns assemby language into machine code - each language needs its only unique assembler