> For the complete documentation index, see [llms.txt](https://pythonforstarters.solomonmarvel.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pythonforstarters.solomonmarvel.com/introduction-to-python/variables.md).

# Variables

#### [What are variables?](broken://pages/4njnUglP9cniY8JcF68l) <a href="#what-are-variables" id="what-are-variables"></a>

A variable in Python is a symbolic name that serves as a reference or pointer to an object. Once an object is assigned to a variable, it can be referred to by that name. However, the data is still contained within the object.

In Python, a variable is a named location in memory that stores a value. Variables are used to store data values in programs. When you create a variable, you specify a name for the variable and a value to store in the variable. You can then use the variable name in your program to refer to the value stored in the variable.

For example, you might create a variable named x and assign it the value 10. You can then use the variable x in your program to refer to the value 10.

```
# In this example, the variable x is created and assigned the value 10. 
# You can then use the variable x in your program like this:
variable = 1

# You can also assign a new value to a variable using 
# the assignment operator (=). For example:
variable = 2

# A variable with a type hint
variable_with_type: int = 1

print(variable_with_type) # print the result of our variable
```

#### [Variable Rules in Python](broken://pages/4njnUglP9cniY8JcF68l) <a href="#variable-rules-in-python" id="variable-rules-in-python"></a>

* A variable must start with a letter or the underscore character.
* A variable cannot start with a number.
* A variable can only contain alphanumeric characters and underscores (A-z, 0-9, and \_ )
* Variables are case-sensitive (age, Age and AGE are three different variables)


---

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

```
GET https://pythonforstarters.solomonmarvel.com/introduction-to-python/variables.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.
