pow() Power

Last updated: 2026-09-22

pow() Power

pow(base, exp[, mod]) returns base**exp; the 3-arg form does modular exponentiation efficiently.

CategoryBuilt-in Functions
KindBuilt-in Function
Python Versionall

📝 Syntax

pow(base, exp[, mod])

⚙️ Parameters

base RequiredThe base (a numeric type).
exp RequiredThe exponent (a numeric type).
mod OptionalModulus; when given, computes base**exp % mod efficiently.(Default:None)

Returns:base**exp, or (base**exp) % mod when mod is given.

💥 Raises

▶ Example

Edit the code, press Run, and see the result in the output panel:

Output:

1024
0.125
1
More case studies coming soon — check back later.

❓ FAQ

QAre pow(2, 10) and 2 ** 10 the same?
AThe result is the same (1024). But ** has no three-argument form, while pow(base, exp, mod) computes (base**exp) % mod with fast modular exponentiation, which is noticeably more efficient for large numbers.
QWhat does pow(2, -3) return?
AIt returns 0.125 — a negative exponent yields the floating-point reciprocal, equivalent to 1 / (2**3).
QHow is pow(3, 4, 5) computed?
AFirst 3**4 = 81, then modulo 5 gives 1, equivalent to 81 % 5; however the three-argument form never constructs a huge intermediate result, making it ideal for modular exponentiation of large numbers like RSA.
QWhy does pow(-2, -3, 5) raise a ValueError?
AA negative base combined with a negative exponent cannot define a unique result under modular arithmetic, so Python raises a ValueError; avoid combining a negative base, a negative exponent, and mod.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏