ese-msc / introduction-to-python

"Introduction to Python" course for future Imperial College London MSc students
BSD 3-Clause "New" or "Revised" License
75 stars 94 forks source link

failing assert test while pybryt test succeeding #66

Closed edsml-cc8915 closed 1 year ago

edsml-cc8915 commented 1 year ago

I just finished solving exercise 1.13 and for the first time see the assert test raise an error while the pybryt test passes. Is my solution wrong or can I rely on the pybryt test alone to assess it?

marijanbeg commented 1 year ago

Hi @edsml-8b751625, thank you for raising this issue. Could you please let us know what your solution is? We think that you should make your assert tests pass since they are testing the output of your code.

marijanbeg commented 1 year ago

And what is the assert statement that is failing?

edsml-cc8915 commented 1 year ago

Sure, this is my solution :)

def odd_numbers(n): odd_num = [] i = 1 while i%2 != 0 and i <= n: odd_num.append(i) i = i + 2 print(odd_num)

It is giving me correct output

edsml-cc8915 commented 1 year ago

This is the assert error:

AssertionError Traceback (most recent call last) Cell In[147], line 5 2 import numpy as np 4 res = odd_numbers(10) ----> 5 assert isinstance(res, list) 6 assert len(res) == 5 7 assert np.allclose(res, [1, 3, 5, 7, 9])

AssertionError:

marijanbeg commented 1 year ago

Please remember that your function must return a value, not only print it.