File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change 11---
22title : 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
You can’t perform that action at this time.
0 commit comments