Intro to CS: Lecture 8 - Functions as Objects
Topics: Functions: environments, scope, functions as objects
This is also review for me. Another thing I noticed about this course is that a lot of math examples are used. Math and CS/Programming go hand in hand so I’m not surprised by this. Also, this is MIT, so students are expected to be familiar with basic math, of course.
If a beginner is taking this course, they should have good foundations in math.
Going over frames/scoping. This is great knowledge for a beginner to learn.
One of the scoping examples bit me during an interview, namely the case where a function can reference variables from its parent scope.
The instructor was wrong about one of the other examples, I tested it out in Spyder IDE. But that’s okay, no one is perfect.
A function is an object and can be passed in as an argument to another function and can also be a return value.
In Python all primitive types are objects, including boolean, float, int, etc.