You should use python files (.py) to write functions that you can then import in your jupiter notebook. However, note that if you change a function in an imported python file, you have to restart the kernel and run the import cell again for the changes to take effect. If you just run the import cell again, python notes that the package has already been imported and does not read the file again.