INFO1110 Lecture Notes - Lecture 10: Instance Variable, Class Variable, Presbyterian Polity

90 views5 pages

Document Summary

W e e k s 9 a , 1 1 b. Warning: objects and classes can be particularly confusing at first. A type is a kind of thing, e. g. int and float in python. An object is a thing that may have data and/or particular methods. The type of an object variable is its class. Objects are instances of a particular class. e. g. p = positiveinteger() the object referenced by variable p is an instance of the class. Classes are defined using the class keyword in python. class positiveinteger: number = 0. The constructor does the work of building an instance of the class. It"s the very first bit of code executed/first method called when an instance is created: allocates memory space, execute all developer-defined code. If a constructor is not written, there is a default one in python. class positiveinteger: def __init__(self): self. number = 0 self. A reserved keyword used to reference the instance of the class (the object).

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents