Scientific Computing with Python Projects - Budget App

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/ 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

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:

Expected 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.

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.

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.

Oh, thanks for the clarification!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.