Pyhton 2 to Python 3

I am writing to request your assistance regarding the task of updating Python 2 code to Python 3, specifically for the magic_summation function.

Situation:

  • I have updated the original code from Python 2 to Python 3, making only the minimum necessary changes to ensure compatibility.
  • I ensured not to modify sections marked as “DO NOT REMOVE OR CHANGE THE COMMAND BELOW” and “DO NOT EDIT THIS PART”.
  • I used the recommended versions of Python and NumPy to maintain consistency with the autograder environment.
  • When running the provided unit tests (unittests.py) in my terminal, all tests pass successfully, and the results match the expected outputs.

Issue:

  • Despite passing all unit tests locally, upon submission to the grading platform, I receive an error message indicating that the output is incorrect for certain parameters:

Actions Taken:

  • I have thoroughly reviewed my code to ensure it contains no unintended modifications.
  • I attempted to replicate the autograder environment, including specific versions of Python and NumPy, but the issue persists.
  • I tested the code with different seeds and n values, and in all cases, local results are correct according to the unit tests.

Request:

  • Additional Information: Could you provide details about the exact environment used by the autograder (Python versions, NumPy, specific configurations)?
  • Special Considerations: Is there any additional configuration or consideration I should be aware of when preparing my code for submission?
  • Assistance: I would appreciate any guidance or suggestions to resolve this issue, as I have tried several solutions without success.

Attached to this email:

  • My magic_summation.py file.
  • Screenshots or logs from the terminal showing that all unit tests pass successfully.

I am committed to learning and want to ensure I meet the task requirements accurately. Any help you could provide would be greatly appreciated.

CODE REMOVED FROM MODERATOR

I advise you to perform the assignment in Coursera environment and pass it there first, then you can play in your own environment as much as you wish.

There are tests in the grader that might not be in unittests.

And most importantly, as I mentioned in my previous reply to you make sure to get the latest version. Also, you can always ask the LLM about the error you are getting.

As a matter of fact when you migrate the code from python 2.7 to Python 3 only a few changes are needed.

You need the latest version of all of the course assets.

Can you please provide more details how to get all assets with the latest version? Thank you!

Hi @caca8888,

You can follow the instructions here to get a fresh new copy of the files.

Let us know if this works.

Thanks,
Lucas

Specifically (since this assignment has assets in multiple folders):

  • In the left side-menu, open the File Browser
  • Navigate to the “assignment_part_1” folder
  • Select, right-click, and Delete the “magic_summation.py” and “unittests.py” files.
  • Go to the Lab Help tool (the question-mark inside a circle), and use the “Get latest version” tool. This will give you new copies of the assignment files.
  • You will need to repeat this process for the “assignment_part_2” folder. Delete any .py files and then use “Get latest version” again.

I recommend you also delete and refresh the instructions.md file, since that was updated two weeks ago.