# Type Hinting

### What is Type Hinting?

Type hinting is where you specify the class type that a variable will be, for instance, `str`.

This is mostly for documentation, though it will help with readability and understanding of the code.

## Argument Type

To specify the type of an argument, add a colon after the name and then the class type.

```python
def greet(name: str):
    print("Hello, " + name + "!")

greet("Monty")
```

## Return Type

The type of the returned value can be specified by adding an arrow after the function, followed by the class type and then the colon.

```python
def sum(num1, num2) -> int:
    return num1 + num2

print(sum(1, 2))
```

## Variable Type

Defining the variable type is very similar to an argument type, in fact, exactly the same.

```python
my_var: str = "Hello"
```


---

# Agent Instructions: 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:

```
GET https://deflatedpickle.gitbook.io/python-somewhat-of-a-guide/good-practice/type-hinting.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
