functions in this sectionwe explore the creation of and use of functions in python as we did in section we draw distinction between functions and methods we use the general term function to describe traditionalstateless function that is invoked without the context of particular class or an instance of that classsuch as sorted(datawe use the more specific term method to describe member function that is invoked upon specific object using an object-oriented message passing syntaxsuch as data sortin this sectionwe only consider pure functionsmethods will be explored with more general object-oriented principles in we begin with an example to demonstrate the syntax for defining functions in python the following function counts the number of occurrences of given target value within any form of iterable data set def count(datatarget) = for item in dataif item =targetn + return found match the first linebeginning with the keyword defserves as the function' signature this establishes new identifier as the name of the function (countin this example)and it establishes the number of parameters that it expectsas well as names identifying those parameters (data and targetin this exampleunlike java and ++python is dynamically typed languageand therefore python signature does not designate the types of those parametersnor the type (if anyof return value those expectations should be stated in the function' documentation (see section and can be enforced within the body of the functionbut misuse of function will only be detected at run-time the remainder of the function definition is known as the body of the function as is the case with control structures in pythonthe body of function is typically expressed as an indented block of code each time function is calledpython creates dedicated activation record that stores information relevant to the current call this activation record includes what is known as namespace (see section to manage all identifiers that have local scope within the current call the namespace includes the function' parameters and any other identifiers that are defined locally within the body of the function an identifier in the local scope of the function caller has no relation to any identifier with the same name in the caller' scope (although identifiers in different scopes may be aliases to the same objectin our first examplethe identifier has scope that is local to the function callas does the identifier itemwhich is established as the loop variable