To group sets of code you can use functions. Functions are small parts of repeatable code.
A function accepts parameters. In the example below we have parameter x and y.
Type this program and save it as summation.py
#!/usr/bin/env python3 def f(x,y): return x*y print(f(3,4))
Save the program below as complexfunction.py
#!/usr/bin/env python3 def sum(list): sum = 0 for l in list: sum = sum + l return sum mylist = [1,2,3,4,5] print(sum(mylist))