mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-24 13:31:07 +00:00
5df8aec66c
* GitHub Action formats our code with psf/black @poyea Your review please. * fixup! Format Python code with psf/black push
28 lines
525 B
Python
28 lines
525 B
Python
import math
|
|
|
|
|
|
def perfect_square(num: int) -> bool:
|
|
"""
|
|
Check if a number is perfect square number or not
|
|
:param num: the number to be checked
|
|
:return: True if number is square number, otherwise False
|
|
|
|
>>> perfect_square(9)
|
|
True
|
|
>>> perfect_square(16)
|
|
True
|
|
>>> perfect_square(1)
|
|
True
|
|
>>> perfect_square(0)
|
|
True
|
|
>>> perfect_square(10)
|
|
False
|
|
"""
|
|
return math.sqrt(num) * math.sqrt(num) == num
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import doctest
|
|
|
|
doctest.testmod()
|