Module Code - FINAL
Module Code - FINAL
Module Code:
Module Title:
Name of Class/Group:
Assignment Title:
Student ID Number:
Date of Submission:
Table of Contents
Task: Health and Fitness Tracker........................................................................................................3
1. Algorithm (Pseudocode)..................................................................................................................4
2. Technical Overview..........................................................................................................................6
3.1 Variable Table............................................................................................................................6
3.2 Python Functions........................................................................................................................7
4. Coded Solution................................................................................................................................8
4.1 Python Code Functionality (word written)...................................................................................8
4.2. Python Code Working (Screenshots)......................................................................................18
4. Testing...........................................................................................................................................19
4.1 Testing for Development..........................................................................................................19
4.2 Testing for Evaluation...............................................................................................................23
6. Evaluation and Summary...............................................................................................................27
References.........................................................................................................................................28
PXXXXXXXX FC308 3
1. Algorithm (Pseudocode)
START
Display “Enter Username”
Input: Username
Display “Enter Password”
Input: Password
If username and password match those stored, THEN
Display “ Login Successful”
GO TO Main Menu
ELSE
Display “Login Failed. Try Again.”
Restart Login
END
START
Main Menu
Display:
1. Log Physical Activity
2. Track Nutrition & Calorie Intake
3. Set Fitness Plans
4. View Progress Summary
5. Update Progress
6. Exit
Prompt User to Select an Option
IF choice == 1 Then
Go to Log Physical Activity
START
Prompt User to enter type of activity – running, cycling, walking, meditation.
Prompt User to enter duration in Minutes.
Prompt User to enter level of intensity.
Calculate estimated calories burned
Open ‘Activity_log.txt” in append mode
Write activity type, duration, intensity, and estimated calories.
Display “Activity Logged Successfully”
Return to Main Menu
END
END
ELSE IF Option == 3 Then Go to Set Fitness Plans
START
Prompt User to enter target value each goal type progressively:
1. Weight reduction goal (grams)
2. Calorie burn goal (kcal)
3. Step goal (number of steps)
Open “fitness_plans.txt” and save the selected plan type and target value
Display “Fitness Plan Saved Successfully”
Return to Main Menu
END
START
Calculate progress data using activity, nutrition, and goal records
Display average progressive percentage Summary
Prompt user to select the day of the week for this record
Save the current day’s progress as a percentage to progress_data.txt
Display motivational message
Display “progress saved!”
Return to Main Menu
END
START
Display: “Thank you for using Fitness tracker today. Stay healthy
Prompt user: “press enter to exit…”
END
PXXXXXXXX FC308 6
2. Technical Overview
This section seeks to illustrate how the Health and Fitness Tracker application is built. This app
uses python, a high-level, interpreted language widely adopted rapid development, with clear
syntax, built-in data handling functions, and file I/O capabilities (José, 2021). A simple console
based Python application offers manageable and customizable solution as python is used widely for
prototype and command-line tools due to its readability and accessibility (Pillai, 2017). Therefore,
python helps this project via enabling modular program design through the use of procedural
programming principles where each function like login and setting fitness plans among others
performs a specific well defied task (Ekmekci et al. 2016). The solution employs basic data
structures using “.txt” files which Lee (2015) explains them to be suitable for lightweight and local
applications and align the project’s scope to avoid data base and cloud systems. This method
eliminates the need for database set up which makes its simplicity ideal.
33,34,35 total_duration, total_burned, int These are used to compute the user’s
total_consumed activities in accumulation mode,
including calories burned and food
consumed
60,61,62 activity, str Inputs for physical activities of the user
duration, int
intensity str
77,78 Food_item, calories str Stores the input of calories and
nutrients log entries.
93,95 weight_goal, calorie_goal, step_goal str, Inputs for the user-defined fitness
plans
129 Choice str Captures menu option selected by the
user
193,194 days, day list, str list of weekdays for progress entry
percentage and the selected day
195, 196 choice, str basically for selecting and storing the
day_index, int day of the week for progress
selected_day str
202 today, line str stores formatted date and progress line
for file writing
# User Credentials
# These are used to simulate a login system. No registration included.
users_db = {
"john_doe": "password123",
"mary_smith": "mypassword",
"tom_jones": "fitness2025"
}
# LOGIN FUNCTION
# Prompts the user for login details, checks against the hardcoded database.
def login():
print("Welcome to the Health and Fitness Tracker!")
username = input("Enter your username: ")
password = input("Enter your password: ")
def calculate_progress(username):
total_duration = 0 # Total workout in minutes
total_burned = 0 # Total calories burned (kcal)
total_consumed = 0
# Nutrition log
try:
with open(NUTRITION_FILE, "r") as file:
for line in file:
if username in line:
parts = line.strip().split(", ")
if len(parts) >= 4:
try:
calories = int(parts[3].split()[0])
total_consumed += calories
except:
continue
except:
pass
try:
with open(PLAN_FILE, "r") as file:
printed_goals = set()
PXXXXXXXX FC308 11
choice = input("Choose an option (1–6): ") #this is to get the user’s choice
if intensity == "low":
PXXXXXXXX FC308 13
calories_burned = duration * 4
elif intensity == "medium":
calories_burned = duration * 7
elif intensity == "high":
calories_burned = duration * 10
else:
calories_burned = duration * 5
# The code below represents how activity data is saved with date in activity_log.txt
with open(ACTIVITY_FILE, "a") as file:
date = datetime.datetime.now().strftime("%Y-%m-%d")
file.write(f"{date}, {username}, {activity}, {duration} mins, {intensity}, {calories_burned} kcal\n")
print("Activity Logged Successfully.")
## Nutrition Logging
# This code section logs user’s calories intake
def track_nutrition(username):
print("\nTracking Nutrition and Calories...")
food = input("Enter food name: ")
calories = input("Enter total calories consumed: ")
date = datetime.datetime.now().strftime("%Y-%m-%d")
## Progress Tracking
# This section of code enables the viewing of progress in comparison to the set goal
def view_progress_summary(username):
cal_pct, step_pct, weight_pct, cal_actual, cal_goal, step_actual, step_goal, weight_actual,
weight_goal = calculate_progress(username)
# Below stands a series calculations that are ran by the application to provide averages in
percentage, for calories, steps and weight loss
# Calories
if cal_goal:
print(f"\nCalories Burned: {cal_actual} kcal / {cal_goal} kcal")
print(f"Progress: {cal_pct:.2f}%")
else:
print("\nCalories Burned: Goal not set.")
# Steps
if step_goal:
print(f"\nWorkout Duration: {step_actual} mins (~{step_actual * 100} steps) / {step_goal} steps")
print(f"Progress: {step_pct:.2f}%")
else:
print("\nStep Goal: Goal not set.")
# Weight
PXXXXXXXX FC308 15
if weight_goal:
print(f"\nCalories Toward Weight Goal: {weight_actual} kcal / {weight_goal * 7} kcal")
print(f"Progress: {weight_pct:.2f}%")
else:
print("\nWeight Goal: Goal not set.")
## Update progress
# The code below helps update data, in terms of average fitness performance on a daily basis,
letting the user record each performance on each day of the week.
def update_progress(username, calories_progress, steps_progress, weight_progress):
print("\n--- Update Progress ---")
# The comment serves to encourage users who achieve more than 50% percent and also urge
those who have not attaned that standards to keep working
print(f"\nYour Average Progress: {average_progress:.2f}%")
print(comment)
try:
day_index = int(choice)
PXXXXXXXX FC308 16
today = datetime.datetime.now().strftime("%Y-%m-%d")
line = (f"{today}, {username}, Day: {selected_day}, "
f"Calories Progress: {calories_progress:.2f}%, "
f"Steps Progress: {steps_progress:.2f}%, "
f"Weight Progress: {weight_progress:.2f}%, "
f"Average: {average_progress:.2f}%, "
f"Comment: {comment}\n") # This then becomes how information is stored in the
progress_file.
print("\nProgress saved!")
print(f"{selected_day} | {average_progress:.2f}% → {comment}")
## Exit program
# the users receive a bidding on their exit from the program, which follows the command 6 on the
main menu. This is the code:
def exit_program():
print("Thank you for using Fitness Tracker today. Stay Healthy!")
input("Press Enter to exit...")
if __name__ == "__main__":
main()
PXXXXXXXX FC308 18
Figure 1: The program successfully stores users' info and allows log ins
using this info...(sth along those lines)
4. Testing
PXXXXXXXX FC308 19
Correct
2. 24/7/2025 Selected option 5 prompt to Claimed no separated logic from added share
(update progress) calculate valid option 4 and reused logic so
before selecting progress or progress calculate_progress for progress is
option 4. allow update data option 5 always
available recalculated
in case of
updates
3. 25/7/2025 Invalid Indentation Program No interface corrected the indentation Adams and
on update_progress failed to start was and moved function Ağacan
call inside menu due to displayed outside of “if” block (2014)
PXXXXXXXX FC308 20
4. 25/7/2025 undefined variable should Crashed fixed the typo and Need for
(da) in primarily with Name completed the dictionary testing
view_progress print error: da is references properly functions
summary progress not defined from end to
summary end be for
being assure
that they are
correct
5. 24/7/2025 percentages only on should showed only added calories, steps, Now all
progress summary compare the percentages, and weight to the “def activities are
activity_log without progress summary” to accounted
data, with comparison match the calculation for
the set data
fitness plan
and provide
percentage
PXXXXXXXX FC308 21
6. 24/7/2025 File not found log in and login failed added the new file – .txt files are
undertake user_credention.txt file needed to
user store data
requests and
information
needed by
the program
User credential
file was missing
when editing
through
simple text
editors like
Notepad
(Vasileiou et
al. 2023).
These development tests, provide evidence that early stage programming is affected by overlooked
syntax, file handling and logic sharing errors. With the success of resolving these bugs, the
program’s robustness improved, providing important knowledge function definitions indentations
and the validation of user inputs to avoid crashes. Kumar (2023) explains that the value of iterative
testing and defensive programming are essential in software development.
PXXXXXXXX FC308 23
4. 25/7/20 View set fitness Accepts new “All Fitness Pass Dummy value
25 plan, and record information from plan saved goal =5000
new information Users to be stored successfully”
and used for
calculations for their
fitness goals and
present new
information upon
entry via
responding, “All
fitness plans saved
successfully”
7. 25/7/20 Enter a valid program program says Nothing was These specific
25 day on the says the the correct day changed days represent
update correct and launches a how data is
progress day and parting stored by the
launches comment program to
a parting track the
comment user’s
progress on a
daily basis
PXXXXXXXX FC308 26
The evaluation tests above confirmed that the Health and Fitness tracker met all functional
expectations. This means that the appropriate responses to both valid and invalid user input are
relatable, displaying messages that guide the user effectively. This phase approves the maturity and
readiness of the program to be used or deployed.
PXXXXXXXX FC308 27
Nevertheless, the program faces challenges on no architecture for user registration unless via
server admin, no data validation for calories and also data redundancy which might manifest vie the
appendage to progress data risking conflicting records per user unless overwritten. With a few
adjustment this program can become a perfect personal fitness assistant.
PXXXXXXXX FC308 28
Reference List
Adams, M.D. and Ağacan, Ö.S., 2014. Indentation-sensitive parsing for Parsec. Acm Sigplan
Notices, 49(12), pp.121-132.
https://michaeldadams.org/papers/layout_parsing_2/LayoutParsing2-2014-haskell-authors-
copy.pdf
de Vries, R.J., 2021. Implementation of an automated Systems Engineering Toolset in the DST
project. Delft University of Technology. https://repository.tudelft.nl/file/File_9f89ec14-42c2-45b2-
95fc-aa045af4b7f7
Ekmekci, B., McAnany, C.E. and Mura, C., 2016. An introduction to programming for bioscientists: a
Python-based primer. PLoS computational biology, 12(6), p.e1004867.
https://journals.plos.org/ploscompbiol/article/file?id=10.1371/journal.pcbi.1004867&type=printabl
e
José, U., 2021. Python programming for data analysis. Springer Nature.
https://elib.vku.udn.vn/bitstream/123456789/2468/1/2021.%20Python%20Programming%20for
%20Data%20Analysis.pdf
Kumar, S., 2023. Reviewing software testing models and optimization techniques: an analysis of
efficiency and advancement needs. Journal of Computers, Mechanical and Management, 2(1),
pp.32-46. https://pdfs.semanticscholar.org/e385/edb9fcecc49676b127a7f7bb1148aedefd4e.pdf
Lawnik, M., Pełka, A. and Kapczyński, A., 2020. A new way to store simple text
files. Algorithms, 13(4), p.101. https://www.mdpi.com/1999-4893/13/4/101
Lee, K.D. and Hubbard, S., 2015. Data structures and algorithms with python (Vol. 363).
Berlin/Heidelberg, Germany: Springer.
https://eprints.ukh.ac.id/id/eprint/187/1/2015_Book_DataStructuresAndAlgorithmsWit.pdf
Pillai, A.B., 2017. Software architecture with Python. Packt Publishing Ltd.
https://www.academia.edu/download/63274164/software-architecture-python20200511-14970-
s9e5nw.pdf
Vasileiou, M., Papageorgiou, G. and Tjortjis, C., 2023, July. A Machine Learning Approach for
Effective Software Defect Detection. In 2023 14th International Conference on Information,
Intelligence, Systems & Applications (IISA) (pp. 1-8). IEEE.
https://ieeexplore.ieee.org/iel7/10345839/10345840/10345866.pdf?
PXXXXXXXX FC308 29
casa_token=iQB5DtcLzywAAAAA:dI43zdL8m40AdGzKmoNL38APair2IoSx9u5wVYkMtC7FWas
Cc5zPGoTGKfOu__vHqf8Y9ks2KLBO