CSC148H1 Lecture Notes - Lecture 19: Arity, Init

100 views3 pages
13 Mar 2018
School
Course
Professor
katrinasavvy and 38715 others unlocked
CSC148H1 Full Course Notes
1
CSC148H1 Full Course Notes
Verified Note
1 document

Document Summary

References: code seen in the pictures can be found on the csc148 website: http://www. teach. cs. toronto. edu/~csc148h/winter. To differentiate between module function and method: Indentation: module level functions won"t have any indent before it, self attribute. When to choose module level function over a class level method: when behavior is closely associated with class, make it class level, your design decision. Last lecture, leaf_count, height, arity were implemented as module functions. Note how there is no indent: outside of class tree. Ex: tree implemented as method inside class tree. Indent before height because it is part of class tree. Notice how the code is very similar to the module functions: however, there is an indent. In addition, parameters are called different: c. height() instead of height(x) because it is part of a class, self. children. The same can be done for the other module functions we implemented last class. Self. value = value: copy children if not none, never have a mutable default parameter.

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