---
title: 3.13 Exponentiation
description: "Exponentiation is the mathematical operation of raising one number (called the **base**) to the power of another number (called the **exponent**). In Python, exponentiation is performed using the `**` operator. For example: - `2 ** 3` means `2 × 2…"
url: "https://edcret.in/docs/python-programming/numeric-data-types-python/3-13-exponentiation/"
updated: "2026-07-29"
category: Python Programming / Numeric Data Types
---

# 3.13 Exponentiation

Exponentiation is the mathematical operation of raising one number (called the **base**) to the power of another number (called the **exponent**).

In Python, exponentiation is performed using the `**` operator.

For example:

- `2 ** 3` means `2 × 2 × 2`, which equals `8`.
- `5 ** 2` means `5 × 5`, which equals `25`.

Exponentiation is commonly used in mathematics, physics, engineering, finance, and scientific computing.

---

## Syntax

```
result = base ** exponent
```

### Components

| Component | Description |
| --- | --- |
| `base` | The number to be raised. |
| `**` | Exponentiation operator. |
| `exponent` | The power to which the base is raised. |
| `result` | The computed value. |

---

## Example 1: Square of a Number

**main.py**

```
number = 5

print(number ** 2)
```

### Output

```
25
```

### Explanation

- `5 ** 2` means `5 × 5`.
- The result is `25`.

---

## Example 2: Cube of a Number

**main.py**

```
number = 4

print(number ** 3)
```

### Output

```
64
```

### Explanation

- `4 ** 3` means `4 × 4 × 4`.
- The result is `64`.

---

## Example 3: Any Power

**main.py**

```
print(3 ** 5)
```

### Output

```
243
```

### Explanation

- `3` is multiplied by itself five times.
- Therefore:
  - `3 × 3 × 3 × 3 × 3 = 243`

---

## Example 4: Zero Exponent

**main.py**

```
print(12 ** 0)
```

### Output

```
1
```

### Explanation

- Any non-zero number raised to the power of zero equals `1`.
- Therefore, `12 ** 0` returns `1`.

---

## Example 5: Exponentiation with Floating-Point Numbers

**main.py**

```
print(2.5 ** 2)
```

### Output

```
6.25
```

### Explanation

- The base is a floating-point number.
- `2.5 × 2.5 = 6.25`.
- The result is also a floating-point number.

---

## Example 6: Negative Exponent

**main.py**

```
print(2 ** -3)
```

### Output

```
0.125
```

### Explanation

- A negative exponent represents the reciprocal.
- `2 ** -3` means `1 / (2 ** 3)`.
- Since `2 ** 3` is `8`, the result is `1/8`, or `0.125`.

---

## Example 7: User Input

**main.py**

```
base = int(input("Enter the base: "))
power = int(input("Enter the exponent: "))

print(base ** power)
```

### Sample Input

```
3
4
```

### Output

```
81
```

### Explanation

- The user enters the base and exponent.
- Python raises the base to the specified power.
- `3 ** 4` equals `81`.

---

## Example 8: Exponentiation in an Expression

**main.py**

```
result = (2 + 3) ** 2

print(result)
```

### Output

```
25
```

### Explanation

- Parentheses are evaluated first.
- `2 + 3` equals `5`.
- Then `5 ** 2` equals `25`.

---

## Example 9: Exponentiation with Variables

**main.py**

```
length = 7

area = length ** 2

print(area)
```

### Output

```
49
```

### Explanation

- Variables can be used with the exponentiation operator.
- Here, the square of the variable is calculated.

---

## Example 10: Checking the Return Type

**main.py**

```
print(type(5 ** 2))
print(type(2 ** -2))
```

### Output

```
<class 'int'>
<class 'float'>
```

### Explanation

- `5 ** 2` produces an integer because the result is a whole number.
- `2 ** -2` produces a floating-point value because it represents a fraction (`0.25`).

---

# Common Mistakes

### 1. Using `^` Instead of `**`

**Incorrect**

```
print(2 ^ 3)
```

### Output

```
1
```

**Reason**

The `^` operator performs a **bitwise XOR**, not exponentiation.

**Correct**

```
print(2 ** 3)
```

---

### 2. Confusing Multiplication with Exponentiation

**Incorrect**

```
print(5 * 2)
```

### Incorrect Expectation

```
25
```

### Actual Output

```
10
```

**Reason**

`*` performs multiplication.
Use `**` for exponentiation.

---

### 3. Forgetting Operator Precedence

**Incorrect**

```
print(-2 ** 2)
```

### Output

```
-4
```

**Reason**

Exponentiation has higher precedence than the unary minus.

Python evaluates:

```
-(2 ** 2)
```

**Correct**

```
print((-2) ** 2)
```

### Output

```
4
```

---

### 4. Expecting the Original Variable to Change

**Incorrect**

```
number = 4

number ** 2

print(number)
```

### Output

```
4
```

**Reason**

The exponentiation operator returns a new value.
It does not modify the original variable.

**Correct**

```
number = number ** 2

print(number)
```

---

# Best Practices

- Use `**` instead of repeated multiplication when raising numbers to powers.
- Use parentheses to make complex expressions easier to read.
- Remember that negative exponents produce floating-point results.
- Do not confuse `**` with the bitwise XOR operator (`^`).
- Store the result if it will be used later in the program.

---

# Key Points to Remember

- `**` is the exponentiation operator in Python.
- It raises the base to the specified exponent.
- A power of `0` always returns `1` for any non-zero base.
- Negative exponents produce the reciprocal of the positive power.
- Exponentiation works with integers and floating-point numbers.
- `^` is **not** the exponentiation operator; it performs bitwise XOR.
- The exponentiation operator returns a new value and does not modify the original variable.
