PROBLEM SET 5: BACK TO THE BANK | SOLUTION (CS50 PYTHON)

preview_player
Показать описание


––– DISCLAIMER –––
The following videos are for educational purposes only. Cheating or any other activities are highly discouraged!! Using another person’s code breaks the academic honesty guidelines. This solution is for those who have finished the problem sets and want to watch for educational purposes, learning experience, and exploring alternative ways to approach problems and is NOT meant for those actively doing the problem sets. All problem sets presented in this video are owned by Harvard University.
–––
Рекомендации по теме
Комментарии
Автор

For those with the problem "expected exit code 0, not 1" my solution was that the program would only check with integer results, no $ signs or strings, so for your test to be valid it can only be checked with 0, 20 and 100

marcoantoniomolina
Автор

for those with problems with the check throwing "expected exit code 0, not 1", I think I found out the issue and it is that you have to create just 3 functions to test your function, in the page it says that you must have 3 or more, but it only works with 3, in my first try I had 4, and I had that problem, but when I changed it to 3 it worked correctly

joableandrosuarezcorrea
Автор

you helped me a lot with this one Dors, thank you a lot. Was really struggling to get my head around how check 50 was looking at the code. I was testing the wrong way.

unseenyt
Автор

FOr anyone still having issues with the submission...read the hint to the end

Venormous
Автор

If anyone gets stuck on "correct bank.py passes all test_bank checks" when using check50 on test_bank, know this: that cs50 doesn't use your bank.py file! It uses its own bank.py file which doesn't like it when you test for white space in this case! (such as, value(' hi')) This had me stuck and confused for quite awhile. It was hard to wrap my head around the fact my bank.py fiie wasn't being used in any way to check50 my test_bank.py file or that their version of bank.py they use to test your test_bank.py file wouldn't account for leading spaces.

slavetruthfreedom
Автор

You helped me realize my mistake in the problem. Thank you so much!

aryachakraborty
Автор

Can you please help me out when i ran the check50 it say my code keeps on giving a exit code 1 and not 0 what can i do to fix it?

jay-nova
Автор

for those having "expected exit code 0, not 1" error even though everything is right

- you need to return as an int

ptz
Автор

"if 'hello' in greeting" would accept something like "definitely not starting with hello".

fopperer
Автор

Hi dear I have a problem with assert when I run the pytest return me“ no test ran in 0.01”

gulldukhtar
Автор

The check50 is faulty. It says my test failes to catch case insensitivity and incorrect values which is clearly not true. Even you copy her exact solution, the same issue remains. I don't know how she managed to get all the smily faces via check50

mushfiqurrahman
Автор

I just figured out that it should return an int not "$0" etc.

ducktavian
Автор

jai une question esque quand je fais des error dans check50 la resulta sera diminuer ?

DZSOFT.
Автор

why do u use main function in the test? you can do it with out main()

aimanbaras
Автор

How can I solve it?

Cause
expected exit code 0, not 5
Log
running pytest test_bank.py...
checking that program exited with status 0...

sardarbekomurbekov
Автор

I am literally doing the same thing still check50 gives red frown to me

ompandey
Автор

My solution for test_bank. Writing test blocks is easy. Figuring out where check50 is breaking on their end without error messages is the hard part. The hint section said you should be returning INT and I was returning strings. Some people say striping whitespace was causing them problems. I used greeting.casefold().lstrip() in my bank.py file and I had no problems.

from bank import value

def main():
test_value()
test_numbers()
test_case()

def test_value():
assert value('Hello') == 0
assert value('Hello, Newman') == 0
assert value("What's happening") == 100
assert value("") == 100
assert value('How are you doing?') == 20

def test_numbers():
assert value('10') == 100
assert value('200') == 100

def test_case():
assert value('UPPER') == 100
assert value('HELLO') == 0
assert value('how are you') == 20
assert value('welcome') == 100
assert value('sUP dUde') == 100

if __name__ == "__main__":
main()

MrDelliSanti
Автор

I can pass the CS50 check but can't test it myself.
When I run the program from bank import value
It says ModuleNotFoundError: No module named "bank"

Does anyone know how I can fix that?

yuyum
Автор

I found my problem with check50.
When I run pytest by myself all tests were passed. But after checking with check50 I have got "expected exit code 0, not 1".
In my case problem was in test for "hello" word by $0.
In this test "hello" must be in first place. So "hello Mike" is correct but "Mike hello" wouldn't be correct.

anatoliy
Автор

Getting: 
"expected exit code 0, not 2" when using check50, however pytest works perfectly fine.
Can anyone shed some light on this??
Thank you!

BeardBat
welcome to shbcf.ru