I guess you speak about a beginner question, please correct me if I am wrong.
def ... is used to define a method/function
def <name>([<parameter_name>[, <parameter>]]):
Make sure to have a ':' at the end of your def and to add a defined number of spaces for all lines inside your method.
def f(foo): return foo**2
Either create a new file, enter those lines and press on the play button upper right, or swipe to the right until you are in Console and enter the lines there. Also there you can test your method by writing f(2)
You can also add a print outside method define, this should make sure to make pythonista switch automatically to console view when you execute it (since it would generate an output there)
I also took another approach: write a socket program, define some bytes to request files, checksums etc. something to send files, to receive files, and run the script on pc and pythonista device. add a dict to store timestamp and md5 +pickle to save to file.
This way I ‚sync‘ files between iphone and Pc and can work on both.
Only important thing: whenever you change code, run a sync before changing it on the other device as well. If both timestamps differ and md5 differs then sync creates a file version of your own and one of the remote file.
Then just add that folder on your pc to your preferred version control and do the backup/committa there.