Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # The collectons module is imported to enable the use namedtuples.
- import collections
- # Namedtuple is invoked from the collections module which creates a class whose instances have three attributes which is
- # then assigned a variable.
- GymExercise = collections.namedtuple("GymExercise", ["name", "weight", "reps"] )
- # Variables are assigned the tuple object with values for the attributes.
- squat = GymExercise("squat", 265, 3)
- bench = GymExercise("benchpresss", 185, 5)
- deadlift = GymExercise("deadlift", 225, 6)
- press = GymExercise("press", 120, 8)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement