Example scripts for learning Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Basics
DataCleanup
TextParsing
Utilities
README.md

README.md

PythonTeachingExamples

Example scripts for learning Python. Currently examples are for text parsing for data visualization.

GETTING STARTED
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).

BASICS
Just a few simple scripts to get you started. Covers printing, data types, and basic math operators.

DATA CLEANUP
A few examples of taking messy, real-world data and prepping it for use. (See also the Text Processing > Introduction to Regular Expressions example.)

TEXT PARSING
Basic to intermediate examples on manipulating text.

UTILITIES
Random assortment of (hopefully) useful scripts, mostly based on in-the-moment student questions.

- - -

[ all code available under Creative Commons BY-NC-SA license - feel free to use but please let me know ]