01 - 00 Introduction to Python
We mentioned the pros of using Python as our tool for performing urban science in the Introduction to Notebook and Beyond. In this introductory module we will discuss the basic semantics of the language and get our hands dirty by actually typing and executing the code blocks.
Remeber:
- To run a cell, you can press
Shift+Enter
(to execute and go to next cell) orCtrl+Enter
(to execute and stay on the same cell).- To add an empty cell, press
Esc
to get out of edit mode and press eitherb
key (to add it after the current cell) ora
key (to add it before the current cell).- You can make edits to the code and play around with it. However you cannot save the edits made to this notebook if you are running it on CDF.
Python has following 6 built-in Data-Types:
Type | Description | Example |
---|---|---|
int | Integer values | 123 |
float | Floating point values | 10.12 |
complex | Complex values | 1 + 3j |
bool | Boolean values | True |
str | String values | “Hello” |
NoneType | None value | None |
and 4 Data-Structures
Type | Description | Example |
---|---|---|
list | Ordered collection of values | [1, ‘abc’, 3, 1] |
set | Unordered collection of unique values | {1, ‘abc’, 3} |
tuple | Immutable Ordered collection | (1, ‘abc’, 3) |
dict | Unordered key. value pairs | {‘abc’: 1, ‘def’: 2} |
In this section we will learn about the above Python’s built-in Data-Types and Data-Structures.