Welcome¶ Welcome to Urban Computing Skills Lab. This course is a pre-requisite for your Masters program in Applied Urban Science and Informatics, which immediately begs the question: what is Urban Science? It is actually hard to define Urban Science especially given how ubiquitous the term has become. In my mind, Urban Science is an emerging domain of research at the intersection of interdisciplinary sciences that seeks to exploit the large-scale data, from a variety of sources, to understand and address urban challenges.
00 - 00 Introduction to Python¶ Python¶ Python is a great object-oriented, interpreted, and interactive programming language. It is widely used as general-purpose, high-level programming language. It is ranked among the top 5 programming languages in the world.
Python was conceived in the late 1980s as a teaching and scripting language and has since become an essential tool for many programmers, engineers, researchers, and data scientists across academia and industry.
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) or Ctrl+Enter (to execute and stay on the same cell).
01 - 01 Variables¶As the name implies, a variable is something that can change. A variable is just a way of referring to a memory location used by a python program. Based on the datatype of the variable, the python interpreter allocates the memory and decides what can be stored in the reserved memory. This makes python a dynamically-typed language.
If you are familiar with other programming languages like C, C++ or Java it might be tempting to consider variable as just a container to store data.
01 - 02 Python Strings¶A python string is usually a bit of text that you want to display or use or export out of the program that you are writing (to a file or over the network). Technically, strings are immutable sequence of characters.
We will talk and learn more about sequences in Data Structures module.
Python has a built-in string class called str with many handy features. Python knows you want something to be a string when you enclose the text with either single quotes ( ‘ ) or double quotes ( “
01 - 03 Numeric Types¶In python there are basically 3 built-in Numeric Data-Types
int float complex 01 - 03.01 int¶Integers are the most basic numeric type in python. Any number that does not contain a decimal point is considered as an integer and is of type int.
An interesting difference between the int type in python and other languages is that they are variable precision.
01 - 04 Operators¶ Operators in python are the constructs which can manipulate the value of operands. Simply put when operators are used with one or more than one operand, they produce some result. Consider a basic mathematical addition 1 + 2 in this case, 1 and 2 are operands and + is the operator. Operands can also be variables. Python supports following types of operators: