Python Pow() (With Examples) - Programiz
Có thể bạn quan tâm
Become a certified Python programmer.
ENROLLPopular Tutorials
Getting Started With Python Python if Statement while Loop in Python Python Lists Dictionaries in Python Start Learning PythonPopular Examples
Add two numbers Check prime number Find the factorial of a number Print the Fibonacci sequence Check leap year Explore Python ExamplesReference Materials
Built-in Functions List Methods Dictionary Methods String Methods View allCreated with over a decade of experience.
- Learn
- Practice
- Compete
Certification Courses
Created with over a decade of experience and thousands of feedback.
Learn Python Learn HTML Learn JavaScript Learn SQL Learn DSA View all Courses onBecome a certified Python programmer.
Try Programiz PRO!Popular Tutorials
Getting Started With Python Python if Statement while Loop in Python Python Lists Dictionaries in Python Start Learning Python All Python TutorialsReference Materials
Built-in Functions List Methods Dictionary Methods String Methods View all Python JavaScript C C++ Java R KotlinBecome a certified Python programmer.
Try Programiz PRO!Popular Examples
Add two numbers Check prime number Find the factorial of a number Print the Fibonacci sequence Check leap year All Python ExamplesBuilt-in Functions
- Python abs()
- Python any()
- Python all()
- Python ascii()
- Python bin()
- Python bool()
- Python bytearray()
- Python callable()
- Python bytes()
- Python chr()
- Python compile()
- Python classmethod()
- Python complex()
- Python delattr()
- Python dict()
- Python dir()
- Python divmod()
- Python enumerate()
- Python staticmethod()
- Python filter()
- Python eval()
- Python float()
- Python format()
- Python frozenset()
- Python getattr()
- Python globals()
- Python exec()
- Python hasattr()
- Python help()
- Python hex()
- Python hash()
- Python input()
- Python id()
- Python isinstance()
- Python int()
- Python issubclass()
- Python iter()
- Python list() Function
- Python locals()
- Python len()
- Python max()
- Python min()
- Python map()
- Python next()
- Python memoryview()
- Python object()
- Python oct()
- Python ord()
- Python open()
- Python pow()
- Python print()
- Python property()
- Python range()
- Python repr()
- Python reversed()
- Python round()
- Python set()
- Python setattr()
- Python slice()
- Python sorted()
- Python str()
- Python sum()
- Python tuple() Function
- Python type()
- Python vars()
- Python zip()
- Python __import__()
- Python super()
Python Tutorials
- Python Operators
- Python divmod()
- Python Functions
- Python Mathematical Functions
- Python Iterators
- Python Programming Built-in Functions
Python pow() The pow() method computes the power of a number by raising the first argument to the second argument
Example
# compute 3^4 print(pow(3, 4)); # Output: 81pow() Syntax
The syntax of pow() is:
pow(number, power, modulus [optional])pow() Parameters
The pow() method takes three parameters:
- number- the base value that is raised to a certain power
- power - the exponent value that raises number
- modulus - (optional) divides the result of number paused to a power and finds the remainder: number^power% modulus
pow() Return Value
The pow() method returns:
- number^power - number, raised to a certain power
- number^power % modulus - with the modulus argument
- 1 - if the value of power is 0
- 0 - if the value of number is 0
Example 1: Python pow()
# returns 2^2 print(pow(2, 2)) # returns -2^2 print(pow(-2, 2)) # returns 1/2^2 print(pow(2, -2)) # returns -1/-2^2 print(pow(-2, -2))Output
4 4 0.25 0.25The pow() method helps us find the value of a number raised to a certain power.
In the above example,
- pow(2,2) is 22 - results in 4
- pow(-2,2) is -22 - results in -4
- pow(2,-2) is 1/22 - results in 0.25
- pow(-2,-2) is -1/-22 - results in 0.25
Example 2: pow() with Modulus
x = 7 y = 2 z = 5 # compute x^y % z print(pow(x, y, z))Output
4In the above example, we have raised the number 7 to the power 2 which results in 49.
Since we have used the pow() method with three arguments x, y, and z, the third argument 5 divides the result of 72 and finds the remainder.
That's why we get the output 4.
Also Read:
- Python id()
- Python int()
- Python Program to Compute the Power of a Number
Sorry about that.
How can we improve it? Feedback * Leave this field blankYour builder path starts here. Builders don't just know how to code, they create solutions that matter.
Escape tutorial hell and ship real projects.
Try Programiz PRO- Real-World Projects
- On-Demand Learning
- AI Mentor
- Builder Community
Python References
Python Library
Python print()
Python Library
Python divmod()
Python Library
Python eval()
Python Library
Python max()
Từ khóa » Hàm Pow Trong Python
-
Hàm Pow() được Tích Hợp Sẵn Trong Python Trả Về Giá Trị Của X Với Lũy Thừa Của Y (xy). Nếu Có Tham Số Thứ Ba, Hàm Trả Về X Lũy Thừa Y, Mô đun Z. ... Các Tham Số Của Hàm Pow()
-
Hàm Pow() Trong Python - Học Lập Trình Python - VietTuts
-
Hàm Pow() Trong Python
-
Hàm Pow() Trong Python - Vay Tiền Online Bằng CMND
-
Hàm Pow() Trong Python - Lập Trình Từ Đầu
-
Hàm Pow() Trong Python - Công Nghệ Lập Trình Python - VIETWIKI.VN
-
Hàm Pow() Trong Python
-
Phương Thức Number Pow() Trong Python
-
[BÀI TẬP PYTHON] Hàm... - CLB Lập Trình Full House- Việt Nam
-
Cách Tính Số Mũ Trong Python
-
Mẹo Cách Viết Số Mũ Python - Sốt. VN News
-
Hàm Pow() Trong Python - HKT SOFT
-
Hàm Pow(x,y) được Dùng để Mô Tả Phép Tính Nào Sau đây?