A collection of basic Python examples designed to get a student up and running on the language.
More tutorials and documentation:
- The official Python docs: http://docs.python.org/2/
- LearnPython.org: http://www.learnpython.org/
After you've mastered these examples, also check out:
- More Python snippets I find handy: https://github.com/anthonydb/python-snippets
- Catch the Cat: A text-based game (introduces objects and advanced coding): https://github.com/anthonydb/catch-the-cat
- Tom Meagher's repo for the 2014 NICAR Python mini-bootcamp: https://github.com/tommeagher/pycar14
- Integers
- Decimals
- Strings
- Lists
- Tuples
- Dictionaries
- Slicing
- Mods
- if ... then ... else
- while
- for
- Opening, reading from and writing to files
- Bonus: Word frequency counter
- Using Requests and BeautifulSoup to fetch and parse a web page
- Parsing text with regular expessions
- Applying regular expressions to scraping nuclear reactor data
- Creating functions
- Using the csvkit Python library to handle CSV files