> For the complete documentation index, see [llms.txt](https://docs.arkannis.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.arkannis.net/programming/courses/python-pcap-31-03-course/functions-and-variable-scope/creating-functions.md).

# Creating functions

## Introduction to Functions

**The help function:**

```python
help(print) # You can pass any other function to the help function and this will provide you with info about that particular function
# You just add the name of the function
```

* This shows arguments
* Provides info of what the function does

**The print function:**

```python
# A function does something
print(args) # You pass to a function arguments
```

## Creating your own function:

You define functions with the word `def`

```python
# Defining the function:
def greet_person():
	print("Hello there, this is a greeting...")
	
# Calling the function:
greet_person()
```

## Calling function instances with args:

```python
def greet_person(jiberish): # For this to run it awaits the jiberish arg
	print("Hello there, this is a greeting...")
	
# Calling the function with an arg
greet_person("Taz") # It will not complain as we are adding a arg
```

**To do a more personalized greeting:**

```python
def greet_person(name): 
	print("Hello there " + name + "!")

greet_person("Chris")
# Will print: Hello there Chris!
```

**Adding a default argument to the function:**

* This is used when an arg is not passed to the function

```python
def greet_person(name = "your name"): 
	print("Hello there " + name + "!")
	
greet_person()
# Will print: Hello there your name!
```

**Adding and documenting functions in a prod environment:**

```python
def greet_person(name = "your name"):
	"""
	DOCSTRING: this returns a greeting
	INPUT: name
	OUTPUT: hello ... name
	"""
	print("Hello there " + name + "!")
```

* When you are defining a function the value is a `Parameter`
* When you are calling a function the value is a `Argument`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.arkannis.net/programming/courses/python-pcap-31-03-course/functions-and-variable-scope/creating-functions.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
