[mas 500] intro to programming
DESCRIPTION
TRANSCRIPT
![Page 1: [Mas 500] Intro to Programming](https://reader033.vdocuments.us/reader033/viewer/2022042507/5400dcd48d7f72c4628b45a3/html5/thumbnails/1.jpg)
MAS.500 - Software Module - Rahul Bhargava
Programming 2013.11.08
![Page 2: [Mas 500] Intro to Programming](https://reader033.vdocuments.us/reader033/viewer/2022042507/5400dcd48d7f72c4628b45a3/html5/thumbnails/2.jpg)
Course OutlinePython
How Software WorksProgramming Styles
![Page 3: [Mas 500] Intro to Programming](https://reader033.vdocuments.us/reader033/viewer/2022042507/5400dcd48d7f72c4628b45a3/html5/thumbnails/3.jpg)
![Page 4: [Mas 500] Intro to Programming](https://reader033.vdocuments.us/reader033/viewer/2022042507/5400dcd48d7f72c4628b45a3/html5/thumbnails/4.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022042507/5400dcd48d7f72c4628b45a3/html5/thumbnails/5.jpg)
Why are You Here?
![Page 6: [Mas 500] Intro to Programming](https://reader033.vdocuments.us/reader033/viewer/2022042507/5400dcd48d7f72c4628b45a3/html5/thumbnails/6.jpg)
Python
![Page 7: [Mas 500] Intro to Programming](https://reader033.vdocuments.us/reader033/viewer/2022042507/5400dcd48d7f72c4628b45a3/html5/thumbnails/7.jpg)
–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](https://reader033.vdocuments.us/reader033/viewer/2022042507/5400dcd48d7f72c4628b45a3/html5/thumbnails/8.jpg)
Interactive Console
![Page 9: [Mas 500] Intro to Programming](https://reader033.vdocuments.us/reader033/viewer/2022042507/5400dcd48d7f72c4628b45a3/html5/thumbnails/9.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022042507/5400dcd48d7f72c4628b45a3/html5/thumbnails/10.jpg)
How Software Works
![Page 11: [Mas 500] Intro to Programming](https://reader033.vdocuments.us/reader033/viewer/2022042507/5400dcd48d7f72c4628b45a3/html5/thumbnails/11.jpg)
Instruction Machines
![Page 12: [Mas 500] Intro to Programming](https://reader033.vdocuments.us/reader033/viewer/2022042507/5400dcd48d7f72c4628b45a3/html5/thumbnails/12.jpg)
Parsing
Source: http://goose.ycp.edu/~dhovemey/spring2008/cs496/lecture/lecture1.html
![Page 13: [Mas 500] Intro to Programming](https://reader033.vdocuments.us/reader033/viewer/2022042507/5400dcd48d7f72c4628b45a3/html5/thumbnails/13.jpg)
Compiling
Source: http://goose.ycp.edu/~dhovemey/spring2008/cs496/lecture/lecture1.html
![Page 14: [Mas 500] Intro to Programming](https://reader033.vdocuments.us/reader033/viewer/2022042507/5400dcd48d7f72c4628b45a3/html5/thumbnails/14.jpg)
Running
❖ Step through instructions❖ Access storage as needed
❖ speed of access❖ Generate output
![Page 15: [Mas 500] Intro to Programming](https://reader033.vdocuments.us/reader033/viewer/2022042507/5400dcd48d7f72c4628b45a3/html5/thumbnails/15.jpg)
Programming Approacheshttps://github.com/rahulbot/Programming-Style-Examples
![Page 16: [Mas 500] Intro to Programming](https://reader033.vdocuments.us/reader033/viewer/2022042507/5400dcd48d7f72c4628b45a3/html5/thumbnails/16.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022042507/5400dcd48d7f72c4628b45a3/html5/thumbnails/17.jpg)
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