Imperative programming: using statements to change a program's state.
nums = [1, 2, 4]
for i in range(0, len(nums)):
nums[i] = nums[i] ** 2
Functional programming: expressions, not statements; no side-effects; use of higher-order functions.
list(map(lambda x: x ** 2, [1, 2, 4]))
(map (lambda (n) (expt n 2)) '(1 2 4))
Object-oriented and data-centric programming.
innocent_bee = Bee(5)
horrible_ant = Ant(10)
innocent_bee.fend_off(horrible_ant)
(define t
(tree 3
(list (tree 1 nil)
(tree 2 (list (tree 1 nil) (tree 1 nil))))))
(map label (branches t))
Declarative programming: State goals or properties of the solution rather than procedures.
(.+)@(.+)\.(.{3})
calc_op: "(" OPERATOR calc_expr* ")"
Remember: code isn't just read by computers, it's also read by humans.
Almost anything! Thanks to libraries!
Web scraping: Getting data from webpages by traversing the HTML.
Markov chain: A way to generate a sequence based on the probabalistic next token.
ππ½ Demo: Composing Gobbledygooks
Further learning: urllib2 module, BeautifulSoup docs, N-Gram modeling with Markov chains, CS70/EECS126 for Markov chains
API (Application Programming Interface): A way to access the functionality or data of another program.
Web APIs: A way to access the functionality or data of an online web service. Typically over HTTP or via JavaScript.
Further learning: urllib2 module, The Movie DB API, ProgrammableWeb
Turtle: A library for drawing graphics (as if a pen is controlled by a turtle).
L-system: A parallel rewriting system and a type of formal grammar, developed originally by a biologist to model the growth of plants.
Example: Axiom: A
, Rules: A β AB
, B β A
n = 0 : A
n = 1 : AB
n = 2 : ABA
n = 3 : ABAAB
Further learning: turtle module, Tutorial: Turtles and Strings and L-Systems, Algorithmic Botany: Graphical Modeling using L-systems, L-system examples
NLP includes language modeling, spelling correction, text classification, sentiment analysis, information retrieval, relation extraction, recommendation systems, translation question answering, word vectors, and more.
ππ½ Demo: Sentence trees!
Further learning: NLTK Book, NLTK Sentiment Analysis, Dan Jurafsky's lectures and books, Berkeley classes: INFO 159, CS 288
Further learning: FastAI Documentation, Kaggle ML tutorial, Bias in ML, Berkeley classes: CS182, CS188, CS189
There are so many possible programs that haven't been made yet. What will you make?