.py
is a regular python file. It’s plain text and contains just your code.
.ipynb
is a python notebook and it contains the notebook code, the execution results and other internal settings in a specific format. You can just run .ipynb
on the jupyter environment.
Better way to understand the difference: open each file using a regular text editor like notepad (on Windows) or gedit (on Linux).
Save on git the .ipynb
if you want to show the results of your script for didatic purposes, for example. But if you are going to run your code on a server, just save the .py