In the following we want to introduce the concept of data types (especially) in Python. As explained in the previous chapters, data types are related to the type of information that should be processed or which is stored in a variable. We have already learned that Python (and other programming language) differentiates between numbers and characters. In relation to this there are appropriated data types for this kind of information. Based on the type of data the following atomic built-in data types are available in Python
Kind of information | Data type | |
---|---|---|
text and characters | str |
|
numbers without decimal point | int |
|
numbers with decimal point | float |
|
complex numbers in a mathematical meaning | complex |
|
logical values ([1, 0]; [TRUE, FALSE]) | bool |
Note: The datatype of a variable / information is automatically determined by Python. The associated datatype is assigned by Python itself.
Note: The datatype of a variable is retrieved by using the
type()
function.Note: All these data representations are objects in Python. Although there are a few functions that work on these datatypes, you will find a lot more helpful associated object properties and methods.
Citation
The E-Learning project SOGA-Py was developed at the Department of Earth Sciences by Annette Rudolph, Joachim Krois and Kai Hartmann. You can reach us via mail by soga[at]zedat.fu-berlin.de.
Please cite as follow: Rudolph, A., Krois, J., Hartmann, K. (2023): Statistics and Geodata Analysis using Python (SOGA-Py). Department of Earth Sciences, Freie Universitaet Berlin.