Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfbe2fde

Browse files
authored
Update pow.md
Now the description as well as the content, and code example has been corrected
1 parentfa0de51 commitfbe2fde

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 representingtheUnicode code pointofthat character.
3+
description:The pow() function returnsthepowerofa 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 (i.e., base** exp).
17+
pow(base, exp, mod): Returns (base** exp) % mod (useful for modular arithmetic).
18+
If the optional mod argument is present, the result is computed more efficiently than base** exp % mod.
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)

[8]ページ先頭

©2009-2025 Movatter.jp