Data Types
For reference, read here.
We have said that a variable refers to a location in memory which contains data. But there are many different types of data. For example, this sentence is a string of characters, we refer to text like this as a string.
There are many ways we can represent numbers. If you wanted to store with the constant PI, to how many decimal places would you store it?
Integers
int
Whole numbers
400
Floating Point
float
Numbers with a decimal
2.134
Complex numbers
complex
Complex number with real and imaginary part
complex(12, 4)
Strings
str
Ordered immutable sequence of characters
“Yoo Hoo!”
Lists
list
Ordered sequence of objects
[12AUG22, “Euro”, 1.123]
Dictionaries
dict
Unordered Key:Value
{index:123, name:”JOR”}
Tuples
tup
Ordered immutable sequence of objects
(12AUG22, “Euro”, 1.123)
Sets
set
Unordered collection of unique objects
{“a”, “b”, “c”}
Booleans
bool
Logical value
True