Why does the class `__dict__` hold only methods and the instance `__dict__` only data — and why call the getter anyway?
Short drills on what this video just taught. Write the code, run the checks, and reveal the answer only if you are stuck.
The class SimpleWorkout from the video is already defined for you, with the constructor that expects a start time string, an end time string and the calories burned. Build one workout that starts at '9/30/2021 1:35 PM', ends at '9/30/2021 1:57 PM' and burned 200 calories. Assign the new object to my_workout.
class SimpleWorkout:
'''A simple class to keep track of workouts'''
def __init__(self, start, end, calories):
self.start = start
self.end = end
self.calories = calories
self.icon = 'sweat'
self.kind = 'Workout'
def get_calories(self):
return self.calories
def get_start(self):
return self.start
def get_end(self):
return self.end
def set_calories(self, calories):
self.calories = calories
def set_start(self, start):
self.start = start
def set_end(self, end):
self.end = end