#!/usr/bin/env python3 # demonstrates of functions # This is global variable. total = 0 # Function definition is here def sum( num1, num2 ): # Add both the parameters and return them." total = num1 + num2; # Here total is local variable. # print ("Inside the function local total") print ("The sum of {:.2f} and {:.2f} is {:.2f}".format(num1,num2,total)) return total # Now you can call sum function #sum( 10, 20 ) #Output #The sum of 10.00 and 20.00 is 30.00 #print ("Outside the function global total : ", total ) #Output #Outside the function global total : 0