Topics: Object Oriented Programming: dunder methods, examples
Lecture Notes
Lecture 18: More Python Class Methods
Readings
Ch 10.1
Finger Exercise Lecture 18
Write the class according to the specifications below:
class Circle():
def __init__(self, radius):
""" Initializes self with radius """
# your code here
def get_radius(self):
""" Returns the radius of self """
# your code here
def __add__(self, c):
""" c is a Circle object
Returns a new Circle object whose radius is
the sum of self and c's radius """
# your code here
def __str__(self):
""" A Circle's string representation is the radius """
# your code here