Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Daily Python Projects
- Build a Gym Workout Tracker with Python
- Level 1: Beginner
- https://dailypythonprojects.substack.com/p/build-a-gym-workout-tracker-with
- This program helps you track your workout routines, sets, reps, and weights. It lets you add exercises, record your progress, and review past workouts. Perfect for gym users who want to log their progress.
- """
- workout = {
- 'Burpee':[{'session':1, 'sets':3, 'reps':10, 'weight':5},{'session':2, 'sets':3, 'reps':10, 'weight':7}],
- 'Leg extension':[{'session':0, 'sets':0, 'reps':0, 'weight':0}]
- }
- def add_exercise(name):
- name = name.capitalize().strip()
- if name not in workout:
- workout[name]=[{'session':0, 'sets':0, 'reps':0, 'weight':0}]
- print (f"Added exercise: {name}")
- return
- else:
- print ("The exercise is registered. Try again.")
- return
- def add_log(name: str, sets: int, reps: int, weight: float):
- name = name.capitalize().strip()
- if name in workout:
- if workout[name][0]['session'] == 0:
- workout[name][0] = {'session':1, 'sets':sets, 'reps':reps, 'weight':weight}
- else:
- n_sessions = len(workout[name])
- workout[name].append({'session':n_sessions + 1, 'sets':sets, 'reps':reps, 'weight':weight})
- def view_progress():
- for exercise, data in workout.items():
- print (f"\nProgress for {exercise}: ")
- for data_session in data:
- print (f"Session {data_session['session']}: {data_session['sets']} sets of {data_session['reps']} reps at {data_session['weight']} kg")
- def main():
- choice = 0
- while True:
- print ("\n🦾 Gym Tracker Options:\n")
- print ("1. Add Exercise")
- print ("2. Log Workout")
- print ("3. View Progress")
- print ("4. Exit ")
- choice = int(input("Select a option: "))
- if choice == 1:
- exercise_name = input ("Enter exercise name: ").capitalize()
- add_exercise(exercise_name)
- elif choice == 2:
- exercise_name = input ("Enter exercise name: ")
- sets = int(input ("Enter sets number: "))
- repts = int(input ("Enter repetions number: "))
- weight = float(input ("Enter the lifting weight: "))
- add_log(exercise_name, sets, repts, weight)
- elif choice == 3:
- view_progress()
- elif choice == 4:
- break
- else:
- print ("Invalid option. Try again")
- follow = input("Do you want to do other operation? (S/N): ").lower()
- if follow == 'n':
- break
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement