Overview |
What is a data type?
- A classification identifying a type of data.
- Each data type specifies what kind of data is stored within it.
Built-in data types
- In most programming languages, there is a set of built-in data types.
The built-in data types for Python that we commonly use are:
int — used for integer numbers
float — used for decimal (or floating point) numbers
str — used for strings (a sequence of characters)
bool — used to hold either True or False (boolean)
list — used to store multiple values of other data types in an ordered sequence
set — used to store multiple values of other data types in an unordered sequence
dict — used to store information in key-value pair (dictionary)
|
String and string literal |
|
Immutable data type |
- An immutable data type is a type of a variable (or an object)
whose value cannot be changed after its creation.
int , float , and str are
immutable data types
- A variable with this type can be reassigned but a reference
from a variable is going to point to somewhere else in memory.
|
Mutable data type |
- A mutable data type is a type of a variable (or an object)
whose value can be changed after its creation.
list , set , and dict
are mutable data type.
- A variable with this type can be reassigned.
A reference from a variable still points the same place in memory
|