Python Basics

Violet Whitney
Sep 3, 2018 · 2 min read

Processing is a programming language and visual development environment.
Python is a high level programming language commonly used by data scientists. We will run the Python language in Processing. Technically speaking we are actually running a language called“jython” which allows us to write in the same syntax as Python while the language is seamlessly integrated with Java. For more Python help check out the following link:

File Names

Python Code Cheat Sheet

  • Comments are made with a #. Comments are not executable code, they are meant to describe code for the programmer’s reference.
  • Data Types
  • Variables — A variable can have a short name (like x and y) or a more descriptive name (age, carName, total_volume). A variable name can only contain alpha-numeric characters and underscores (A-z, 0–9, and _ ), and are case sensitive (age, Age and AGE are three different variables). They are often written like this in camelCase or CamelCase .
  • local variable are declared inside a function, and can be used only inside that function
  • global variable are declared outside any function, and they can be accessed (used) on any function in the program
  • Operators — perform operations on variables and values
  • List is a collection which is ordered and changeable. Allows duplicate members.
  • Tuple is a collection which is ordered and unchangeable. Allows duplicate members.
  • Set is a collection which is unordered and unindexed. No duplicate members.
  • Dictionary is a collection which is unordered, changeable and indexed. No duplicate members.
  • Arrays — store multiple values in one single variable
  • If — math logic that executes if statement meets the condition set
  • Else — math logic that executes if statement doesn’t meet the condition set (catches anything which isn’t caught by the preceding conditions)
  • While Loop — execute a set of statements as long as a condition is true.
  • For Loop — iterate over a sequence (avlist, a tuple, a dictionary, a set, or a string)
  • Functions — block of code which only runs when called, which allows data (parameter) to be passed in and can return a result
  • Classes — an object constructor, or a “blueprint” for creating objects
  • JSON — a structured list

Data Mining the City

Graduate course at Columbia University GSAPP, taught by Violet Whitney and TA Zeid Ghawi

Violet Whitney

Written by

Spatial tech, design computation, organizational behavior, equity, and gifs. Adjunct Assist Professor @ColumbiaGSAPP. PM, @SidewalkLabs.

Data Mining the City

Graduate course at Columbia University GSAPP, taught by Violet Whitney and TA Zeid Ghawi

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade