CSE 163
Inheritance�
Suh Young Choi��🎶 Listening to: Alan Becker�💬 Before Class: Before was was was, was was is. Ruminate!�
This Time
Last Time
2
Announcements
Checkpoint 3 due next Monday!
THA 4: Networks due next Thursday! (Please start early ☺ )
Project EDA + Portfolio Milestone released Monday
Section 5 extended to 11:59pm today
3
Project EDA
Exploratory Data Analysis
Provide update to your Proposal
Answer some guided questions about each dataset that you are working with
Slightly adjusted requirements if you are pursuing the Multiple Datasets or Result Validity challenge goals
Submit a 3-5 page report (soft upper limit of 8 pages) + the code you have used to answer the questions + testing code
4
Portfolio Milestone
Polish work for THA 1, 2, and 3
Provide update to your Vision Statement
Revise and reflect on your chosen Creative Components
Slightly adjusted requirements if you are pursuing the Narrative Portfolio or Technical Deep Dive challenge goals
Submit a 3-5 page writeup (soft upper limit of 8 pages) + the code you have revised from your THAs
5
Lambdas
Introduce: Lambda functions– these let us define functions within the body of our code!
6
def get_dog_name(d):
return d.get_name()
sorted(dogs, key=get_dog_name)
sorted(dogs, key=lambda d: d.get_name())
Main Method Pattern
7
def main():
print('Hello world')
if __name__ == '__main__':
main()
Special Methods
8
Syntax | Method |
x < y | x.__lt__(y) |
x > y | x.__gt__(y) |
x == y | x.__eq__(y) |
x <= y | x.__le__(y) |
x >= y | x.__ge__(y) |
print(x) | print(x.__str__()) |
x[i] | x.__getitem__(i) |
x[i] = v | x.__setitem__(i, v) |
Inheritance
9
class Dog:
def __init__(self, name: str) -> None:
self._name: str = name
�
def bark(self) -> None:
print(self._name + ': Woof')
�
class ServiceDog(Dog):
def __init__(self, name: str, service: str) -> None:
super().__init__(name)
self._service: str = service
�
def bark(self) -> None:
print(self._name + ‘: *alert bark*')
�
Graphs
10
THA 4 Tips
11
Before Next Time
Next Time
12