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>]]):
Command1
Command2
Command3
...
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)