Primitive data types
Variables and types are two concepts shared by most programming languages. Variables are kind of like reserved spaces for values of certain type. Each variable has a name and associated value, which can be an
- integer — e.g. -45, 0, 1, 202, …
- floating point number — e.g. 3.14, 0.0007, 2e10, …
- character — e.g. ‘a’, ‘b’, …
- string — a series of characters
- object — some composite structure that is itself composed of values of different types,
- …
Different programming languages expose different primitive data types,
for example, Python has list
(a list of objects) and dict
(a hash table
of objects) and many more types.
Example
variable name | variable type | example value (of variable) |
---|---|---|
counter | int | 2 |
hello_text | str | "Hello, world!" |
PI | float | 3.1415926 |
list_of_ints | list | [4, 1, 2, 0] |
The choice of variable name lies with the programmer. The code is only readable when names are chosen wisely.
Task
Your task is to get familiar with basic data types that are available in almost all programming languages, regardless of your preference.
Read the full Wiki article on topic and possibly follow all the linked pages too.
Use LibreOffice Calc (a solid Microsoft Excel replacement) to create a spreadsheet of tabular information comparing different popular types.
Some of the information you MUST include is:
- common type names across various computer languages (Python, C, Java, … — Google it!),
- length of objects of certain type (in bytes),
- for what kind of data can the type be used most effectively,
- basic operations that could be executed upon type,
- for what kind of data the type shouldn’t be used (due to logical of performant ineffectivenes in that situation).
You are welcome to include your own notes and remarks. Once finished, submit the spreadsheet for evaluation.