1.4.1a - primitive data types (y12) Flashcards
What is a data type?
The classification of data (e.g. integer, boolean, string).
What is an integer?
A whole number (e.g. -2, 0, 5).
What is a real/float?
A number with decimals (e.g. 3.14).
What is a character?
A single letter, number, or symbol.
What is a string?
A sequence of characters (e.g. “Hello”).
What is a boolean?
A value that is either TRUE or FALSE.
Why are data types important?
They define what operations can be performed on data.
What is casting?
Changing a variable from one type to another.
How do you cast to integer in Python?
int(x)
How do you cast to string in Python?
str(x)
What is data validation?
Checking that input data has the correct format/type.
What is overflow?
When a value exceeds storage capacity of its data type.
What is underflow?
When a value is too small for its data type to represent.
What is truncation?
Cutting off digits after the decimal point.
What is rounding?
Adjusting a number to the nearest whole or decimal place.
What is the difference between ASCII and Unicode?
ASCII uses 7/8 bits, Unicode supports more characters globally.
What is a bit?
A binary digit – 0 or 1.
What is a byte?
8 bits.
How many values can 1 byte represent?
256 different values (0–255).
What data type would you use for age?
Integer.
What data type would you use for price?
Float/Real.
What data type would you use for a postcode?
String.
Why use booleans?
To store logical values and control decisions.