1/14
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Data type
The kind of data a variable contains, it can be character, string, integer, real or boolean
Character
The data type of a single character e.g. "A" or "$"
String
This data type stores a series of characters, e.g. "Zak", "MK44 5AB" or "123456789"
Integer
The data type of a whole number e.g. 5, 999 or -4
Boolean
This data type has only two values, TRUE and FALSE
Real
A data type for real numbers, also called floating point numbers or floats, they have a decimal part, for example 1.5, 0.935 or the value of Pi
Casting
Changing the data type using a function such as int() or str()
int("12")
This expression uses a casting function to change a string to an integer and results in the integer value 12
str(12.8)
This expression uses a casting function to change a float to a string and results in the string value "12.8"
float("12.8")
This expression uses a casting function to change a string to a float and results in the real value 12.8
input()
A function that inputs a value from the keyboard. In Python this always returns a string so we must cast this to integer or float if we need it to be numeric
int(input())
Returns the integer value of some input from the keyboard (in both Exam Reference Language and Python)
Comparison
This type of operation always returns a boolean value, because it answers a question such as age > 18 or answer == "Yes"
Arithmetic
This type of operation returns either integer or float values because it performs a numeric calculation such as fare * 2.5 or sum(temps)
Logic
This type of operation always returns a boolean value (True or False) because it performs boolean operations on other boolean expressions