Advertisement
Dammiejoy20

Untitled

Mar 29th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. # The collectons module is imported to enable the use namedtuples.
  2. import collections
  3.  
  4. # Namedtuple is invoked from the collections module which creates a class whose instances have three attributes which is
  5. # then assigned a variable.
  6. GymExercise = collections.namedtuple("GymExercise", ["name", "weight", "reps"] )
  7.  
  8. # Variables are assigned the tuple object with values for the attributes.
  9. squat = GymExercise("squat", 265, 3)
  10. bench = GymExercise("benchpresss", 185, 5)
  11. deadlift = GymExercise("deadlift", 225, 6)
  12. press = GymExercise("press", 120, 8)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement