Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions docs/builtin/pow.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Python pow() built-in function - Python Cheatsheet
description: Given a string representing one Unicode character, return an integer representing the Unicode code point of that character.
description: The pow() function returns the power of a number.
---

<base-title :title="frontmatter.title" :description="frontmatter.description">
Expand All @@ -12,16 +12,27 @@ Python pow() built-in function
From the <a target="_blank" href="https://docs.python.org/3/library/functions.html#pow">Python 3 documentation</a>
</base-disclaimer-title>
<base-disclaimer-content>
Given a string representing one Unicode character, return an integer representing the Unicode code point of that character.
The pow() function returns the power of a number.It takes two or three arguments:
pow(base, exp): Returns base raised to the power of exp (base ** exp).
pow(base, exp, mod): Returns (base ** exp) % mod (for modular arithmetic).
Result is computed more efficiently than base ** exp % mod, if mod arg is present.
</base-disclaimer-content>
</base-disclaimer>

## Example

```python
>>> result = pow(2, 3)
>>> print(result)
# Basic exponentiation
>>> pow(2, 3)
# 8

# Using three arguments (modular exponentiation)
>>> pow(2, 3, 5)
# 3 (since 2^3 = 8, and 8 % 5 = 3)

# Works with negative exponents (returns float)
>>> pow(2, -3)
# 0.125 (since 2^(-3) = 1/8)
```


Expand Down