Basic elements of Python¶
In this lesson we will revisit data types, learn how data can be stored in Python lists, and about the concept of objects in programming. If you have not already started Spyder you should do so now. You can find directions on how to open Spyder at the start of Lesson 1.
Like the previous lesson, this lesson is inspired by the Programming with Python lessons from the Software Carpentry organization.
Data types revisited¶
We saw a bit about variables and their values in the lesson last week, and we continue today with some variables related to FMI observation stations in Finland. For each station, a number of pieces of information are given, including the name of the station, an FMISID, its latitude, its longitude, and the station type. We can store this information and some additional information for a given station in Python as follows:
In : stationName = 'Helsinki Kaivopuisto' In : stationID = 132310 In : stationLat = 60.15 In : stationLong = 24.96 In : stationType = 'Mareographs'
Here we have 5 values assigned to variables related to a single observation station. Each variable has a unique name and they can store different types of data.
We can explore the different types of data stored in variables using the
In : type(stationName) Out: str In : type(stationID)