[mas 500] intro to programming

17
MAS.500 - Software Module - Rahul Bhargava Programming 2013.11.08

Upload: rahulbot

Post on 30-Aug-2014

224 views

Category:

Education


2 download

DESCRIPTION

 

TRANSCRIPT

Page 1: [Mas 500] Intro to Programming

MAS.500 - Software Module - Rahul Bhargava

Programming 2013.11.08

Page 2: [Mas 500] Intro to Programming

Course OutlinePython

How Software WorksProgramming Styles

Page 3: [Mas 500] Intro to Programming
Page 4: [Mas 500] Intro to Programming

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)

Page 5: [Mas 500] Intro to Programming

Why are You Here?

Page 6: [Mas 500] Intro to Programming

Python

Page 7: [Mas 500] Intro to Programming

–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.

Page 8: [Mas 500] Intro to Programming

Interactive Console

Page 9: [Mas 500] Intro to Programming

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

Page 10: [Mas 500] Intro to Programming

How Software Works

Page 11: [Mas 500] Intro to Programming

Instruction Machines

Page 12: [Mas 500] Intro to Programming

Parsing

Source: http://goose.ycp.edu/~dhovemey/spring2008/cs496/lecture/lecture1.html

Page 13: [Mas 500] Intro to Programming

Compiling

Source: http://goose.ycp.edu/~dhovemey/spring2008/cs496/lecture/lecture1.html

Page 14: [Mas 500] Intro to Programming

Running

❖ Step through instructions❖ Access storage as needed

❖ speed of access❖ Generate output

Page 15: [Mas 500] Intro to Programming

Programming Approacheshttps://github.com/rahulbot/Programming-Style-Examples

Page 16: [Mas 500] Intro to Programming

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

Page 17: [Mas 500] Intro to Programming

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