Example scripts for learning Python. Currently examples are for text parsing for data visualization.
We'll be writing code in a text editor - I recommend one of the following:
Python is a scripting language that is very powerful, but easy to get started with. It should come pre-installed on your computer! To check, open your command line:
- Mac users:
Applications > Utilities > Terminal
- PC users:
Start > All Programs > Accessories > Command Prompt
To see if Python is set up, type
python into the window - you should get a bunch of information on which version you have set up.
WRITING YOUR FIRST SCRIPT
All Python scripts (programs) will be written in your text editor and saved with the
.py extension. See the
Basics folder for some simple examples.
Once written, you can run your script using the following:
- Text Wrangler:
#! > Run in Terminal...
- Sublime Text:
Tools > Build... (or command/control B)
Your script should run, either in the Terminal window (Text Wrangler) or in the built-in console (Sublime Text).
Just a few simple scripts to get you started. Covers printing, data types, and basic math operators.
A few examples of taking messy, real-world data and prepping it for use. (See also the
Text Processing > Introduction to Regular Expressions example.)
Basic to intermediate examples on manipulating text.
Random assortment of (hopefully) useful scripts, mostly based on in-the-moment student questions.
- - -