paper 2 - section 5 - programming Flashcards
name 5 different data types
- integer
- real (or float)
- boolean
- character
- string
what is the pseudocode for an integer?
int
what is the pseudocode for a real (or float)?
real
what is the pseudocode for boolean?
bool
what is the pseudocode for character
char
what is the pseudocode for a string?
string
what type of data do integers hold?
whole numbers only
what type of data do reals (or floats) hold?
numbers that have a decimal part
what are the characteristics of boolean data types?
they can take one of two values, usually true or false
what type of data does the character data type hold?
a single letter, number or symbol
what type of data do strings hold?
a collection of characters - strings are used to represent text
what are the benefits of using the correct data types?
using the correct data types makes code more memory efficient, robust and predictable
Each data type is allocated a different amount of memory. how much is the typical amount of memory taken up for an integer?
2 bytes or 4 bytes
Each data type is allocated a different amount of memory. What is the typical amount of memory taken up by a real (or a float)?
4 bytes or 8 bytes
Each data type is allocated a different amount of memory. What is the typical amount of memory taken up by a boolean value?
1 bit is needed but 1 byte is usually used
Each data type is allocated a different amount of memory. What is the typical amount of memory taken up by a character?
1 byte
Each data type is allocated a different amount of memory. What is the typical amount of memory taken up by a string?
1 byte for every character in the string
what is the difference between weakly typed and strongly typed languages?
weakly types languages will try to convert data types to avoid errors, however this can lead to unpredictable results.
Strongly typed languages won’t try to convert data types and so will produce more errors but more predictable results.
what is casting used for?
it’s used to change the data type
programming languages have functions that let you manually convert between data types. What is this known as?
casting
name 4 commands that can be used in casting
- int()
- float()
- bool()
- str()
what does the function ASC( ) do?
allow you to find the ASCII number of characters (e.g. ASC(“b”) would convert the character “b” into its ASCII number 98)
what does the function CHR( ) do?
it allows you to convert an ASCII number into a letter (e.g. CHR(98) would convert the ASCII number 98 into its equivalent character “b”)
what do the arithmetic operators do?
they take two values and perform a maths function on them