Skip to content

Commit efb1757

Browse files
authored
Merge pull request #480 from gspagare/patch-2
Update pow.md
2 parents fa0de51 + 6d63483 commit efb1757

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

docs/builtin/pow.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Python pow() built-in function - Python Cheatsheet
3-
description: Given a string representing one Unicode character, return an integer representing the Unicode code point of that character.
3+
description: The pow() function returns the power of a number.
44
---
55

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

1922
## Example
2023

2124
```python
22-
>>> result = pow(2, 3)
23-
>>> print(result)
25+
# Basic exponentiation
26+
>>> pow(2, 3)
2427
# 8
28+
29+
# Using three arguments (modular exponentiation)
30+
>>> pow(2, 3, 5)
31+
# 3 (since 2^3 = 8, and 8 % 5 = 3)
32+
33+
# Works with negative exponents (returns float)
34+
>>> pow(2, -3)
35+
# 0.125 (since 2^(-3) = 1/8)
2536
```
2637

2738

0 commit comments

Comments
 (0)