Ok, so, lots of changes here. The exercises have now been split into separate categories according to their type, and now the user is prompted to input their preferences for each type. Also, the end result is now printed to an external file, so that the user can just open it up and then print it out directly from their text editor. I still need to finish separating the exercises into their categories though.

This commit is contained in:
William Brawner 2015-06-23 14:55:54 -05:00
parent cb7ce3d8d4
commit 8216323ddc
2 changed files with 186 additions and 123 deletions

View file

@ -1,42 +1,73 @@
#Create different classes for each muscle group and store a list of exercises in each.
class Muscle_Group(object):
#Exercises should be separated according to the equipment used.
class Chest(object):
exercises = []
selectorized = ["Seated Chest Press", "Seated Fly"]
dumbbell = ["Dumbbell Chest Press", "Dumbbell Flies", "Inclined Dumbbell Chest Press", "Declined Dumbbell Chest Press",]
barbell = ["Barbell Chest Press", "Inclined Barbell Chest Press", "Declined Barbell Chest Press"]
cable = ["Cable Crossovers"]
calisthenics = ["Push Ups", "Inclined Push Ups", "Stability Ball Pushups", "Medicine Ball Push Ups"]
class Chest(Muscle_Group):
exercises = ["Push Ups","Barbell Chest Press", "Dumbbell Chest Press","Dumbbell Flies","Cable Crossovers","Inclined Dumbbell Chest Press","Inclined Barbell Chest Press","Declined Dumbbell Chest Press","Declined Barbell Chest Press"]
class Back(object):
exercises = []
selectorized = []
dumbbell = ["Dumbbell Bent-Over Row",]
barbell = ["Barbell Bent-Over Row",]
cable = ["Seated Cable Row", "Seated Cable Lat-Pulldown"]
calisthenics = ["Pull Ups",]
class Back(Muscle_Group):
exercises = ["Pull Ups","Barbell Bent-Over Row","Seated Cable Row","Dumbbell Bent-Over Row","Seated Lat-Pulldown"]
class Legs(object):
exercises = []
selectorized = ["Leg Press", "Quadriceps Extensions", "Hamstring Curls"]
dumbbell = []
barbell = ["Barbell Deadlifts",]
cable = []
calisthenics = ["Squats"]
class Legs(Muscle_Group):
exercises = ["Squats", "Deadlifts", "Leg Press", "Quadriceps Extensions", "Hamstring Curls"]
class Lower_Legs(object):
exercises = []
selectorized = ["Smith Press Calf Raises", "Leg Press Calf Raises"]
dumbbell = ["Dumbbell Calf Raises", ]
barbell = []
cable = []
calisthenics = []
class Lower_Legs(Muscle_Group):
exercises = ["Dumbbell Calf Raises", "Smith Press Calf Raises", "Leg Press Calf Raises"]
class Biceps(Muscle_Group):
class Biceps(object):
exercises = ["Dumbbell Preacher Curls", "Dumbbell Hammer Curls", "Barbell Preacher Curls", "Cable Hammer Curls", "Cable Preacher Curls"]
selectorized = []
dumbbell = []
barbell = []
cable = []
calisthenics = []
class Triceps(Muscle_Group):
class Triceps(object):
exercises = ["Overhead Dumbbell Triceps Extensions", "Overhead Cable Triceps Extensions", "Narrow-Grip Barbell Bench Press", "Narrow-Grip Dumbbell Bench Press", "Weighted Dips", "Cable Triceps Pull-Down"]
selectorized = []
dumbbell = []
barbell = []
cable = []
calisthenics = []
class Shoulders(Muscle_Group):
class Shoulders(object):
exercises = ["Dumbbell Lateral Flies", "Dumbbell Shoulder Press", "Barbell Shoulder Press", "Cable Reverse Crossover"]
selectorized = []
dumbbell = []
barbell = []
cable = []
calisthenics = []
class Forearms(Muscle_Group):
class Forearms(object):
exercises = ["Barbell Wrist Flexion", "Barbell Wrist Extension", "Weighted String Flexion", "Weighted String Extension"]
selectorized = []
dumbbell = []
barbell = []
cable = []
calisthenics = []
class Abs(Muscle_Group):
class Abs(object):
exercises = ["Crunches", "Dead Bugs", "Hanging Leg Lifts", "Windshield Wipers", "Planks", "Flutter Kicks"]
selectorized = []
dumbbell = []
barbell = []
cable = []
calisthenics = []

224
workoutgenerator.py Normal file → Executable file
View file

@ -1,9 +1,9 @@
from random import sample
from exercises import *
log = open("/home/billy/Desktop/Workout.txt", "w")
#Create the generator class which will actually create the routines according to the desired number of days per week.
class Generator(object):
days = input("How many days would you like to workout this week?\n>>> ")
#Get input from user for goals and store it in a variable called "goal".
goal = input("Is your goal to gain strength, endurance, or hypertrophy?\n>>> ")
goal = goal.lower()
@ -12,7 +12,7 @@ class Generator(object):
sets = "5-8"
target_reps = "1-6"
actual_reps = "__/__/__/__/__/__/__/__"
template = '| {:^35} | {:^7} | {:^6} | {:^12} | {:^27} |'
template = '| {:^38} | {:^7} | {:^6} | {:^12} | {:^24} |'
elif "endurance" in goal:
sets = "1-3"
target_reps = "15-20"
@ -25,6 +25,9 @@ class Generator(object):
template = '| {:^50} | {:^7} | {:^6} | {:^12} | {:^12} |'
else:
print ("Sorry, please try again.")
#Ask the user how many days per week they want to work out and store that number in a variable called
#"days".
days = input("How many days would you like to workout this week?\n>>> ")
#Loop through the input request until the user gives a number. The loop continues until a number is given.
while True:
try:
@ -34,13 +37,42 @@ class Generator(object):
days = input("How many days would you like to workout this week?\n>>> ")
else:
break
def user_preference(equipment0, equipment1, equipment2, equipment3, equipment4, equipment5, equipment6, equipment7, equipment8, name):
preference = input("Do you like doing {!s} exercises?\n>>> ".format(name))
if "y" in preference:
for exercise in equipment0:
Chest.exercises.append(exercise)
for exercise in equipment1:
Back.exercises.append(exercise)
for exercise in equipment2:
Legs.exercises.append(exercise)
for exercise in equipment3:
Lower_Legs.exercises.append(exercise)
for exercise in equipment4:
Biceps.exercises.append(exercise)
for exercise in equipment5:
Triceps.exercises.append(exercise)
for exercise in equipment6:
Shoulders.exercises.append(exercise)
for exercise in equipment7:
Forearms.exercises.append(exercise)
for exercise in equipment8:
Abs.exercises.append(exercise)
elif "n" in preference:
pass
else:
print ("Sorry, please try inputting yes or no.")
user_preference(Chest.selectorized, Back.selectorized, Legs.selectorized, Lower_Legs.selectorized, Biceps.selectorized, Triceps.selectorized, Shoulders.selectorized, Forearms.selectorized, Abs.selectorized, "selectorized equipment")
user_preference(Chest.dumbbell, Back.dumbbell, Legs.dumbbell, Lower_Legs.dumbbell, Biceps.dumbbell, Triceps.dumbbell, Shoulders.dumbbell, Forearms.dumbbell, Abs.dumbbell, "dumbbell")
user_preference(Chest.barbell, Back.barbell, Legs.barbell, Lower_Legs.barbell, Biceps.barbell, Triceps.barbell, Shoulders.barbell, Forearms.barbell, Abs.barbell, "barbell")
user_preference(Chest.calisthenics, Back.calisthenics, Legs.calisthenics, Lower_Legs.calisthenics, Biceps.calisthenics, Triceps.calisthenics, Shoulders.calisthenics, Forearms.calisthenics, Abs.calisthenics, "calisthenics")
user_preference(Chest.cable, Back.cable, Legs.cable, Lower_Legs.cable, Biceps.cable, Triceps.cable, Shoulders.cable, Forearms.cable, Abs.cable, "cable equipment")
#If the user only wants to work out 1 day of the week, a full body workout will be generated.
if days == 1:
#The format for the header.
print("-" * 103)
print('| {:^99} |'.format("You should workout at least 2-3 times a week, but if you can only manage one day this week,"))
print('| {:^99} |'.format("here's your routine:"))
print("|", "-" * 99, "|")
print("-" * 103, file = log)
print('| {:^99} |'.format("Full Body Day"), file = log)
print("|", "-" * 99, "|", file = log)
#The sample method grabs a number of random exercises from the given list and stores it in a variable according to the exercise.
chest_exercises = sample(Chest.exercises, 1)
back_exercises = sample(Back.exercises, 1)
@ -51,105 +83,105 @@ class Generator(object):
shoulders_exercises = sample(Shoulders.exercises, 1)
forearms_exercises = sample(Forearms.exercises, 1)
abs_exercises = sample(Abs.exercises, 1)
print (template.format("Exercise", "Weight", "Sets", "Target Reps", "Actual Reps"))
print("|", "-" * 99, "|")
print (template.format("Exercise", "Weight", "Sets", "Target Reps", "Actual Reps"), file = log)
print("|", "-" * 99, "|", file = log)
#This section prints out the exercises in a list according to the template above.
for item in chest_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
for item in back_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
for item in legs_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
for item in lower_legs_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
for item in biceps_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
for item in triceps_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
for item in shoulders_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
for item in forearms_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
for item in abs_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print("|", "-" * 99, "|")
print('| {:^99} |'.format("Complete this routine for 2-3 weeks and then come generate a new one!"))
print("-" * 103)
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
print("|", "-" * 99, "|", file = log)
print('| {:^99} |'.format("Complete this routine for 2-3 weeks and then come generate a new one!"), file = log)
print("-" * 103, file = log)
#A 2 day split should consist of an upper body and a lower body day.
elif days == 2:
print("-" * 103)
print('| {:^99} |'.format("Upper Body Day"))
print("|", "-" * 99, "|")
print("-" * 103, file = log)
print('| {:^99} |'.format("Upper Body Day"), file = log)
print("|", "-" * 99, "|", file = log)
chest_exercises = sample(Chest.exercises, 2)
back_exercises = sample(Back.exercises, 2)
biceps_exercises = sample(Biceps.exercises, 1)
triceps_exercises = sample(Triceps.exercises, 1)
shoulders_exercises = sample(Shoulders.exercises, 1)
forearms_exercises = sample(Forearms.exercises, 1)
print (template.format("Exercise", "Weight", "Sets", "Target Reps", "Actual Reps"))
print("|", "-" * 99, "|")
print (template.format("Exercise", "Weight", "Sets", "Target Reps", "Actual Reps"), file = log)
print("|", "-" * 99, "|", file = log)
for item in chest_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
for item in back_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
for item in biceps_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
for item in triceps_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
for item in shoulders_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
for item in forearms_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print("|", "-" * 99, "|")
print('| {:^99} |'.format("Lower Body Day"))
print("|", "-" * 99, "|")
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
print("|", "-" * 99, "|", file = log)
print('| {:^99} |'.format("Lower Body Day"), file = log)
print("|", "-" * 99, "|", file = log)
legs_exercises = sample(Legs.exercises, 3)
lower_legs_exercises = sample(Lower_Legs.exercises, 2)
abs_exercises = sample(Abs.exercises, 2)
print (template.format("Exercise", "Weight", "Sets", "Target Reps", "Actual Reps"))
print("|", "-" * 99, "|")
print (template.format("Exercise", "Weight", "Sets", "Target Reps", "Actual Reps"), file = log)
print("|", "-" * 99, "|", file = log)
for item in legs_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
for item in lower_legs_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
for item in abs_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print("|", "-" * 99, "|")
print('| {:^99} |'.format("Complete this routine for 2-3 weeks and then come generate a new one!"))
print("-" * 103)
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
print("|", "-" * 99, "|", file = log)
print('| {:^99} |'.format("Complete this routine for 2-3 weeks and then come generate a new one!"), file = log)
print("-" * 103, file = log)
#A 3 day split will have a chest day, back day, and leg day.
elif days == 3:
print("-" * 103)
print('| {:^99} |'.format("Chest Day"))
print("|", "-" * 99, "|")
print("-" * 103, file = log)
print('| {:^99} |'.format("Chest Day"), file = log)
print("|", "-" * 99, "|", file = log)
chest_exercises = sample(Chest.exercises, 3)
triceps_exercises = sample(Triceps.exercises, 2)
shoulders_exercises = sample(Shoulders.exercises, 2)
print (template.format("Exercise", "Weight", "Sets", "Target Reps", "Actual Reps"))
print("|", "-" * 99, "|")
print (template.format("Exercise", "Weight", "Sets", "Target Reps", "Actual Reps"), file = log)
print("|", "-" * 99, "|", file = log)
for item in chest_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
for item in triceps_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
for item in shoulders_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print("|", "-" * 99, "|")
print('| {:^99} |'.format("Back Day"))
print("|", "-" * 99, "|")
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
print("|", "-" * 99, "|", file = log)
print('| {:^99} |'.format("Back Day"), file = log)
print("|", "-" * 99, "|", file = log)
back_exercises = sample(Back.exercises, 3)
biceps_exercises = sample(Biceps.exercises, 2)
forearms_exercises = sample(Forearms.exercises, 2)
print (template.format("Exercise", "Weight", "Sets", "Target Reps", "Actual Reps"))
print("|", "-" * 99, "|")
print (template.format("Exercise", "Weight", "Sets", "Target Reps", "Actual Reps"), file = log)
print("|", "-" * 99, "|", file = log)
for item in back_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
for item in biceps_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
for item in forearms_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print("|", "-" * 99, "|")
print('| {:^99} |'.format("Leg Day"))
print("|", "-" * 99, "|")
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
print("|", "-" * 99, "|", file = log)
print('| {:^99} |'.format("Leg Day"), file = log)
print("|", "-" * 99, "|", file = log)
legs_exercises = sample(Legs.exercises, 3)
lower_legs_exercises = sample(Lower_Legs.exercises, 2)
abs_exercises = sample(Abs.exercises, 2)
@ -161,61 +193,61 @@ class Generator(object):
print (template.format(item, '_____', sets, target_reps, actual_reps))
for item in abs_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print("|", "-" * 99, "|")
print('| {:^99} |'.format("Complete this routine for 2-3 weeks and then come generate a new one!"))
print("-" * 103)
print("|", "-" * 99, "|", file = log)
print('| {:^99} |'.format("Complete this routine for 2-3 weeks and then come generate a new one!"), file = log)
print("-" * 103, file = log)
#A 4 day split should have a Chest Day, Back Day, Leg Day, and Shoulder/Forearm/Ab Day
elif days == 4:
print("-" * 103)
print('| {:^99} |'.format("Chest Day"))
print("|", "-" * 99, "|")
print("-" * 103, file = log)
print('| {:^99} |'.format("Chest Day"), file = log)
print("|", "-" * 99, "|", file = log)
chest_exercises = sample(Chest.exercises, 4)
triceps_exercises = sample(Triceps.exercises, 3)
print (template.format("Exercise", "Weight", "Sets", "Target Reps", "Actual Reps"))
print("|", "-" * 99, "|")
print (template.format("Exercise", "Weight", "Sets", "Target Reps", "Actual Reps"), file = log)
print("|", "-" * 99, "|", file = log)
for item in chest_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
for item in triceps_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print("|", "-" * 99, "|")
print('| {:^99} |'.format("Back Day"))
print("|", "-" * 99, "|")
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
print("|", "-" * 99, "|", file = log)
print('| {:^99} |'.format("Back Day"), file = log)
print("|", "-" * 99, "|", file = log)
back_exercises = sample(Back.exercises, 4)
biceps_exercises = sample(Biceps.exercises, 3)
print (template.format("Exercise", "Weight", "Sets", "Target Reps", "Actual Reps"))
print("|", "-" * 99, "|")
print (template.format("Exercise", "Weight", "Sets", "Target Reps", "Actual Reps"), file = log)
print("|", "-" * 99, "|", file = log)
for item in back_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
for item in biceps_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print("|", "-" * 99, "|")
print('| {:^99} |'.format("Leg Day"))
print("|", "-" * 99, "|")
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
print("|", "-" * 99, "|", file = log)
print('| {:^99} |'.format("Leg Day"), file = log)
print("|", "-" * 99, "|", file = log)
legs_exercises = sample(Legs.exercises, 4)
lower_legs_exercises = sample(Lower_Legs.exercises, 3)
print (template.format("Exercise", "Weight", "Sets", "Target Reps", "Actual Reps"))
print("|", "-" * 99, "|")
print (template.format("Exercise", "Weight", "Sets", "Target Reps", "Actual Reps"), file = log)
print("|", "-" * 99, "|", file = log)
for item in legs_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
for item in lower_legs_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print("|", "-" * 99, "|")
print('| {:^99} |'.format("Arm Day"))
print("|", "-" * 99, "|")
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
print("|", "-" * 99, "|", file = log)
print('| {:^99} |'.format("Arm Day"), file = log)
print("|", "-" * 99, "|", file = log)
shoulders_exercises = sample(Shoulders.exercises, 3)
forearms_exercises = sample(Forearms.exercises, 3)
abs_exercises = sample(Abs.exercises, 3)
print (template.format("Exercise", "Weight", "Sets", "Target Reps", "Actual Reps"))
print("|", "-" * 99, "|")
print (template.format("Exercise", "Weight", "Sets", "Target Reps", "Actual Reps"), file = log)
print("|", "-" * 99, "|", file = log)
for item in shoulders_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
for item in forearms_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
for item in abs_exercises:
print (template.format(item, '_____', sets, target_reps, actual_reps))
print("|", "-" * 99, "|")
print('| {:^99} |'.format("Complete this routine for 2-3 weeks and then come generate a new one!"))
print("-" * 103)
print (template.format(item, '_____', sets, target_reps, actual_reps), file = log)
print("|", "-" * 99, "|", file = log)
print('| {:^99} |'.format("Complete this routine for 2-3 weeks and then come generate a new one!"), file = log)
print("-" * 103, file = log)
#If the user tries to input more than 6 days, a warning comes up that they should rest at least one day and
#no workout is generated. In the future I'd like to make this loop so that it continues until the number
#given is less than 7.