This content originally appeared on CodeSource.io and was authored by Ariessa Norramli
In this article, you will learn how to square a number in Python.
Let’s say you have an integer named ‘a’ with value 22.
a = 22
In order to calculate the square of a number, you can use the pow()
method.
a = 22
print(pow(a, 2))
# => 484
Note: The pow()
method functions by raising the first argument to the power of the second argument.
The post How to Square A Number in Python appeared first on CodeSource.io.
This content originally appeared on CodeSource.io and was authored by Ariessa Norramli
Ariessa Norramli | Sciencx (2021-02-23T11:57:52+00:00) How to Square A Number in Python. Retrieved from https://www.scien.cx/2021/02/23/how-to-square-a-number-in-python/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.