Assignment Submission by Ahumuza Ivan
Assignment Submission by Ahumuza Ivan
UoPeople
Ask the user to input their fixed expenses (e.g., rent, utilities).
Ask the user if they have more variable expenses to input. If yes, continue
the loop; if no, exit the loop.
Sum the fixed expenses and the total of the variable expenses to get
total_expenses.
Python
Variable_expenses_list = []
While True:
If variable_expense == 0:
Break
Variable_expenses_list.append(variable_expense)
Total_variable_expenses = sum(variable_expenses_list)
Debugging Techniques
Print Statements:
Insert print statements at key points in the algorithm to display the values
of variables and the flow of execution. This can help identify where the
miscalculation occurs.
Example:
Python
Input Validation:
Check the user inputs for unexpected values or formats that could lead to
miscalculations. Ensure that the input for expenses is numerical and non-
negative.
Unit Testing:
Create test cases with known inputs and expected outputs to verify the
correctness of the algorithm. This can help isolate the specific scenario
causing the miscalculation.
Debugger Tools:
Code Review:
Have another person review the algorithm code to identify any logical
flaws or potential sources of miscalculation.
By employing these debugging techniques and tools, you can pinpoint the
specific logical error in the algorithm and make the necessary adjustments
to ensure accurate budget calculations.