I'm not quite sure I understand what you mean by "degrade in context" - care to elaborate?
# %%
foo = 1
# %%
print(foo)
Above is notebook with two "cells" & also a valid Python script. Perhaps it matters less with SQL vs Python, but it's a nice property.