[mas 500] intro to programming
DESCRIPTION
TRANSCRIPT
MAS.500 - Software Module - Rahul Bhargava
Programming 2013.11.08
Course OutlinePython
How Software WorksProgramming Styles
My Guidelines❖ we will use python as a learning language (I will give you lots
of example code)❖ I will survey existing tools for each topic (but I’ll introduce
you to just one or two)❖ I will bring in people to give examples (because you need to
build something to get your degree)❖ you will get out as much as you put in (I aim to help
beginners, intermediates, and experts)❖ you will learn how to learn (because you won’t become a
programer overnight)
Why are You Here?
Python
–PEP 20 (The Zen of Python)
Beautiful is better than ugly.Explicit is better than implicit.Simple is better than complex.
Complex is better than complicated.Readability counts.
Interactive Console
Modules & Packages❖ any file is a “module”❖ packages: “App Store” for re-usable code via pip or
easy_install❖ logging, testing, etc.❖ Make your own: folder-based hierarchy with the
magic __init__.py file❖ https://wiki.python.org/moin/UsefulModules❖ https://pypi.python.org/pypi
How Software Works
Instruction Machines
Parsing
Source: http://goose.ycp.edu/~dhovemey/spring2008/cs496/lecture/lecture1.html
Compiling
Source: http://goose.ycp.edu/~dhovemey/spring2008/cs496/lecture/lecture1.html
Running
❖ Step through instructions❖ Access storage as needed
❖ speed of access❖ Generate output
Programming Approacheshttps://github.com/rahulbot/Programming-Style-Examples
Programming Approaches❖ Imperative
❖ Everything is global, doesn’t scale well❖ Procedural
❖ Make procedures to separate things❖ Object-Oriented
❖ Encapsulate complexity via abstraction❖ Event-Driven
❖ Limit scope to reduce complexity❖ Functional
❖ Functions operate on data so you don’t manage state❖ demos
Homework❖ setup python (v2.7)❖ setup git (github.com has great instructions)❖ clone this repo: https://github.com/rahulbot/Programming-Style-Examples❖ push homework to a git repository (github or ❖ beginner:
❖ modify an example to count total votes counts for each person❖ intermediate:
❖ create an election results module to encapsulate all the loading, add methods for accessing total vote counts and other features
❖ advanced:❖ build a module that scrapes (use BeautifulSoup) more detailed election data
❖ http://www.archives.gov/federal-register/electoral-college/2012/popular-vote.html❖ add the ability to export it to CSV and JSON