lundi 8 novembre 2021

Schedule module with random.sample repeating output

import random
import schedule
import time

def main():
    print('YOUR WORKOUT SCHEDULE')

#MONDAYS
def monday_workouts():
    mond_chest_compound = ['Bench Press','Incline Bench','Flat Dumbbell Press','Incline Dumbbell Press']
mond_chest_non = ['Cable Flies','Dumbbell Pull Overs','Dips','Push-ups','Hammer Bench']
mond_biceps = ['Barbell Curls','Hammer Curl','Incline Dumbbell Curl',
           'Cable Curl','Chin-Up','Concentration Curls','Rope Curls','Dual Cable Curls','High Cable Curl']
mond_chest_workouts = (random.sample(mond_chest_compound,k=1)) + (random.sample(mond_chest_non,k = 3))
mond_bicep_workouts = random.sample(mond_biceps,k=4)
print(mond_chest_workouts,'\n',mond_bicep_workouts)


#WEDNESDAYS
def wednesday_workouts():
wed_back_compound = ['Bent Over Rows','T-Bar Rows','Dumbbell Rows','Pull Ups']
wed_back_non = ['Lat Pull Down','Close Grip Pull Down','Single-Arm Cable Row','Seated Row']
wed_triceps = ['Cable Tricep Push-downs','Tricep Dips','Over-Head Extensions','Skull Crushers',
           'Close Grip Extensions(V Bar)','Rope Push-downs','Diamond Push-ups','Single Arm Over-Head Extensions']
wed_abs = ['Machine Crunches','Machine Leg-Ups','Hanging Leg Raises','Twists','Laying Ab Crunches']

wed_back_workouts = (random.sample(wed_back_compound,k=1)) + (random.sample(wed_back_non,k = 3))
wed_triceps_workouts = random.sample(wed_triceps,k=4)
wed_abs_workouts = random.sample(wed_abs,k=2)
print(wed_back_workouts,'\n',wed_triceps_workouts,'\n', wed_abs_workouts)


#FRIDAYS
def friday_workouts():
fri_shoulders_compound = ['Seated Over-Head Press','Standing Barbell Over-Head Press','Dumbbell Over-Head Press','Arnold Press']
fri_shoulders_non = ['Lateral Raises','Front Raises','Face Pulls','Reverse Flies','Upright Rows','Rear Delt Flies','Y-Pulls']
fri_traps = ['Heavy Dumbbell Shrugs','Heavy Barbell Shrugs','Rope Shrugs','Seated Shrugs']

fri_shoulders_workouts = (random.sample(fri_shoulders_compound,k=1)) + (random.sample(fri_shoulders_non,k = 3))
fri_traps_workouts = random.sample(fri_traps,k=2)
print(fri_shoulders_workouts,'\n',fri_traps_workouts)

#SATURDAYS
def saturday_workouts():
sat_legs_compound = ['Heavy Squats','Light Squats']
sat_semi_compound = ['Leg Press','Hack Squats','Close Stance Smith Squats']
sat_legs_non = ['Leg Extensions','Hamstring Curls','Wall Sits Timed']
sat_calves = ['Standing Calf Raises','Seated Calf Raises','Inward/Outward Calf Raises']
sat_abs2 = ['Machine Crunches','Machine Leg-Ups','Hanging Leg Raises','Twist']

sat_legs_workouts = (random.sample(sat_legs_compound,k=1)) + (random.sample(sat_semi_compound,k=1)) + (random.sample(sat_legs_non,k = 2))
sat_calves_workouts = random.sample(sat_calves,k=2)
sat_abs2_workouts = random.sample(sat_abs2,k=2)
print(sat_legs_workouts,'\n',sat_calves_workouts,'\n', sat_abs2_workouts)


#Schedule
schedule.every().monday.at("10:10").do(monday_workouts)
schedule.every().wednesday.at("10:10").do(wednesday_workouts)
schedule.every().friday.at("10:10").do(friday_workouts)
schedule.every().saturday.at("10:10").do(saturday_workouts)

#See all jobs pending
all_jobs = schedule.get_jobs()
print(all_jobs)

while True:
    schedule.run_pending()
    time.sleep(1)

if __name__ == "__main__":
    main()

The code above executes properly. Although when the new week starts, it "randomizes" the exact same workouts as the previous week. Is there an issue with my code?

Example: Last Monday I had the EXACT SAME workouts as this Monday. Now I know that it can not be a coincidence. There must be an issue with the schedule portion of the program.




Aucun commentaire:

Enregistrer un commentaire