I&C SCI 33 Lecture Notes - Lecture 2: Function Object, Special Functions

52 views3 pages

Document Summary

Functions: defining a function f refers to a function, defining g = f would make g refer to the same function that f refers to, names are represented in diagrams by boxes. Binds names to objects: names always refer to objects in python, you can loop through lists/dictionaries of functions (making references to those functions), and call those functions. Function calls returning references to function objects: def bigger_than(v): def test(x): return x > v return test, calling x = bigger_than(5) sets v = 5, then if you call x(6) you will get a value of true. Functions vs. methods: recall: a method call is a special function call. In python, you can do x, y = y, x. Python computes all the expressions/objects on the right and binds the names on the left to these values/objects (bind x to 2 then y to 1) Aka sequence unpacking assignment l, m, (n, o) = (1, 2, [3, 4])

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents