Freecodecamp: Scientific Computing with Python Projects - Budget App - README.md - check_funds method.

Created on 1 Aug 2020  路  10Comments  路  Source: freeCodeCamp/freeCodeCamp

I think the description of the check_funds method (https://repl.it/@freeCodeCamp/fcc-budget-app#README.md) is faulty.

Screenshot from 2020-08-01 07-20-24

It should be:
"A check_funds method that accepts an amount as an argument. It returns False if the amount is greater than the balance of the budget category and returns True otherwise. This method should be used by both the withdraw method and transfer method." This is more logical, makes the code simpler and actually works with the tests.


  • Browser Version: Firefox 79 on Ubuntu Linux
  • Operating System: Ubuntu 20.04 LTS
first timers only learn

All 10 comments

this is genuinely a mistake as how can the amount which needs to be withdrawn be more than the balance in the ledger. amount can only be withdrawn if it is less than the balance in ledger. however there can be a probability that a part of that amount can be deducted from balance but the challenge stated nothing for the same. also the test module asked for a False return value which i think is wrong here in the challenge.
errorsnap

Hello! Has any resolution to this been implemented? Im not entirely sure what to do about submitting this project because this error still exists. Any help is greatly appreciated!

I don't think so, README.md hasn't changed. It doesn't matter though, design the project as if it was modified the way I suggested and it'll be fine.

Thank you, for opening this.

For anyone reading, before a fix: Change this:

def test_check_funds(self):
        self.food.deposit(10, "deposit")
        actual = self.food.check_funds(20)
        expected = False
        self.assertEqual(actual, expected, 'Expected `check_funds` method to be False')
        actual = self.food.check_funds(10)
        expected = True
        self.assertEqual(actual, expected, 'Expected `check_funds` method to be True')

To this in the test_module.py file:

def test_check_funds(self):
        self.food.deposit(20, "deposit")
        actual = self.food.check_funds(10)
        expected = False
        self.assertEqual(actual, expected, 'Expected `check_funds` method to be False')
        actual = self.food.check_funds(20)
        expected = True
        self.assertEqual(actual, expected, 'Expected `check_funds` method to be True')

@scissorsneedfoodtoo Can I get a sanity check here? What needs to change on the fCC repl account?
I am opening this up to first-timers only

Here is the repo: https://github.com/freeCodeCamp/boilerplate-budget-app

The README description makes sense, but the tests do not, in my opinion. So, the README does not need to change.

Thanks for your patience and for catching this @carbasemin. Also, thanks for @ mentioning me, @Sky020. Sorry I didn't see this sooner.

My first thought is that we don't need to change the test, but just the README like @carbasemin suggested. It seems like check_funds is supposed to be used by the other methods to make sure that there's a sufficient balance before calling withdraw or transfer. So in the current test:

def test_check_funds(self):
        self.food.deposit(10, "deposit")
        actual = self.food.check_funds(20)
        expected = False
        self.assertEqual(actual, expected, 'Expected `check_funds` method to be False')
        actual = self.food.check_funds(10)
        expected = True
        self.assertEqual(actual, expected, 'Expected `check_funds` method to be True')

It makes sense that the first condition is false and the second is true -- you shouldn't be able to buy $20 worth of food if your food budget is only $10. It's just that the current instructions in the README doesn't reflect that.

@beaucarnes, is that what you were thinking for the check_funds method?

Also, to answer your question @Sky020, once we decide what to do here and fix things in the boilerplate repo, someone on the team can sign into Repl.it and mirror those changes.

@scissorsneedfoodtoo Thanks for that. I was thinking about the use of the check_funds method in an odd way.

I'm willing to work on this one if it's agreed that the README needs to be changed instead of the test.

@IamSurrett Thanks, for your eagerness and patience. I was a bit quick with approving the change to be made.

So, right now, I suggest you leave your current PR open as is. Once we come to a consensus here, we will be sure to let you know which changes (if any) to make on your PR.

@Sky020, no problem. I think it could work the other way around, we would just need to change the description a bit more and maybe change the method name to something like over_budget.

I heard back from @beaucarnes and he agrees that changing the README makes the most sense. The wording that @carbasemin suggested sounds good to me.

Just mirrored the changes from @IamSurrett's PR in the Repl.it project: https://repl.it/@freeCodeCamp/fcc-budget-app#README.md

Thanks again everyone for your suggestions, reviews, and for this fix.

Was this page helpful?
0 / 5 - 0 ratings