Reading-Notes
Code Fellows Python 401
Read: 09 - Ten Thousand Game 4
Dunder Methods
- dunder/”magic” methods let you emulate the behavior of built-in types
Object Initialization:
__init__ - cunstructor that takes care of setting up the object
Object Representation: __str__, __repr__
__repr__: The “official” string representation of an object. This is how you would make an object of the class. The goal of repr is to be unambiguous.
__str__: The “informal” or nicely printable string representation of an object. This is for the enduser.
Iteration: len, getitem, reversed
Operator Overloading for Comparing Accounts: eq, lt
Operator Overloading for Merging Accounts: add
Callable Python Objects: call
Context Manager Support and the With Statement: enter, exit
Statistics - Probability
Probability
At the most basic level, probability seeks to answer the question, “What is the chance of an event happening?” An event is some outcome of interest. To calculate the chance of an event happening, we also need to consider all the other events that can occur. The quintessential representation of probability is the humble coin toss.