When should I insert a new cell

At what point in the code steps do I start a new cell? Do I just keep adding it to the bottom of the first cell? This doesn’t seem like it would be very clean or efficient. Any answer is greatly appreciated. Thanks!

In line with the concept of modularisation, I try to keep codes that perform a particular operation in one cell. It also helps in tracing errors. When you run a cell, you can quickly see that it is performing its function or not.

You can build upon a block of code in a cell, the exact size of the block depends on the individual.

I believe this question is best answered/learned through your own experience.

Have you met any issues with putting too much code in one cell or across too many cells? ?
If yes what were they? Do you have any code samples?
Then we can discuss how to break it up, or which parts are good to go together.
Else, it’s just a matter of preference.
It’s the same code, runs the same, and gives the same effect (assuming no asynchronous operations), assuming they’re in same order, no matter in one cell or multiple cells.

Convenient alt/shift/ctrl+enter running and also downstream decisions like moving from .ipynb to .py (using %%writefile) will inform cell splits.

1 Like

Thank you for taking time to answer my question.