+ 1

Debug debut code projects?

Is there no way to debug or run partial bits of code when doing code project. Since the task requires at least some lines of code it is getting a bit hard to just do trial and error with the hidden test cases without clues to where I get it wrong. I’m working on the last assignment in the intermediate python course. EDIT: Which involves reading files.

2nd May 2022, 6:59 PM
Daniel E
4 Respostas
+ 3
Daniel E , what you can use is an online debugger. there is one named "python tutor". you can copy code and insert it. then you can run the code in step mode forth and back. during this process, you can see the flow of your code, also all variables with there content if you have input() function used, the required data can be entered when you are asked to do so. other than in playground, the input is given as in a regular ide. here is a link with a short code, that you can use. don't worry about the link itself, it contains the url and also the snippet code: https://pythontutor.com/visualize.html#code=a%20%3D%20int%28input%28%29%29%0Ab%20%3D%20int%28input%28%29%29%0Ac%20%3D%20int%28input%28%29%29%0Atotal%20%3D%20a%20%2B%20b%20%2B%20c%0Aif%20total%20in%20range%28100,%20200%2B1%29%3A%0A%20%20%20%20print%28%22sum%20is%20in%20range%22%29%0Aelse%3A%0A%20%20%20%20print%28%22sum%20out%20of%20range%22%29&cumulative=false&curInstr=6&heapPrimitives=nevernest&mode=display&origin=opt-frontend.js&py=3&rawInputLstJ
2nd May 2022, 7:40 PM
Lothar
Lothar - avatar
+ 2
Copy the code, go to Code section, click +, select the programming language, insert your code. Run it.
2nd May 2022, 7:04 PM
Lisa
Lisa - avatar
+ 2
To add to Lisa's answer, when you debug in an ide, you can set breakpoints to stop code wherever you want. You can then view attributes and watch how they change while single stepping through the code
2nd May 2022, 7:27 PM
Slick
Slick - avatar
0
comment the lines that u dont want to run.
3rd May 2022, 8:43 PM
underscore
underscore - avatar