> ## Documentation Index
> Fetch the complete documentation index at: https://python4ai.codewithsiva.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Numbers

> Working with integers and decimals

## Two types of numbers

Python has two ways to store numbers:

**Integers** - Whole numbers without decimals

```python theme={null}
age = 25
score = -10
```

**Floats** - Numbers with decimal points

```python theme={null}
price = 19.99
temperature = -5.5
pi = 3.14159
```

<Tip>
  Python uses a dot (.) for decimals, not a comma. Writing `3,14` creates a tuple, not the number 3.14!
</Tip>

## Why two types?

Python separates integers and floats for efficiency - computers can work with whole numbers faster and more precisely. But here's the reassuring part: in practice, you rarely need to think about this. Python handles the conversion automatically when needed, and most of the time you'll just use whatever makes sense - whole numbers for counting things, decimals for measurements and calculations.

## Basic math operations

Numbers work just like a calculator:

```python theme={null}
# Addition and subtraction
total = 10 + 5     # 15
change = 20 - 7    # 13

# Multiplication and division
area = 6 * 4       # 24
half = 10 / 2      # 5.0 (always returns float)

# Powers
squared = 5 ** 2   # 25
cubed = 2 ** 3     # 8
```

## Integer vs float division

Division has two forms:

```python theme={null}
# Regular division (always float)
result = 10 / 3    # 3.333...

# Integer division (rounds down)
result = 10 // 3   # 3
```

<Tip>
  These are just the basics! Python can solve complex math problems too. When you need square roots, trigonometry, or advanced calculations, ask AI to help with the specific syntax - no need to memorize every math symbol right now.
</Tip>

## Common mistakes

<AccordionGroup>
  <Accordion title="Division always returns float">
    ```python theme={null}
    # Even when dividing evenly
    result = 10 / 2
    print(result)       # 5.0 (not 5)
    print(type(result)) # <class 'float'>

    # Use // for integer result
    result = 10 // 2    # 5
    ```
  </Accordion>

  <Accordion title="Can't use commas in numbers">
    ```python theme={null}
    # Wrong
    million = 1,000,000  # Creates a tuple, not a number!

    # Right
    million = 1000000    # Hard to read
    million = 1_000_000  # Python style
    ```
  </Accordion>
</AccordionGroup>

## What's next?

Now let's learn about working with text in Python!

<Card title="Strings" icon="font" href="/data-types/strings">
  Text and characters
</Card>
