vel
October 24, 2022, 2:01pm
1
Issue with last test case in budget app replit
Percentage is being calculated wrongly in the test cases
My code
[boilerplate-budget-app X - Python Repl - Replit ]
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36
Challenge: Scientific Computing with Python Projects - Budget App
Link to the challenge:
I don’t think that’s true. Can you explain what you mean in more detail?
1 Like
vel
October 24, 2022, 2:29pm
3
If you calculate the percentages based on withdrawals on the left and compare them to my code, according to the challenge’s ‘round to the nearest ten’, mine matches and totals to a 100%. The test results don’t and total to 90%
My result:
That’s because your calculations are wrong.
You deftly avoided my question about why you think your calculations are correct.
I don’t think your rounding is quite right.
vel
October 24, 2022, 2:43pm
6
I’m sorry if I gave such impression. My percentage is calculated like so:
(total_withdrawal_in_a_class_object)/(sum_of_withdrawals_in_all_class_objects) * 100
Then rounded to nearest ten as the challenge dictates, mine calculations are correct.
They really are not correct calculations. When I use correct calculations, my code passes.
I’m suspicious of your rounding. You are rounding up that category when you are required to round down.
The height of each bar should be rounded down to the nearest 10.
vel
October 24, 2022, 2:49pm
8
My rounding uses the round() fuction in python like so:
percentage_spent = int(round((cat.spends/spends_total)*100, -1))
Right. That’s wrong. You aren’t following the instructions.
vel
October 24, 2022, 2:52pm
10
Oh, thanks for the clarification!
system
Closed
April 25, 2023, 2:52am
11
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.