We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8a5633a commit 6d44cddCopy full SHA for 6d44cdd
maths/perfect_square.py
@@ -0,0 +1,27 @@
1
+import math
2
+
3
4
+def perfect_square(num: int) -> bool:
5
+ """
6
+ Check if a number is perfect square number or not
7
+ :param num: the number to be checked
8
+ :return: True if number is square number, otherwise False
9
10
+ >>> perfect_square(9)
11
+ True
12
+ >>> perfect_square(16)
13
14
+ >>> perfect_square(1)
15
16
+ >>> perfect_square(0)
17
18
+ >>> perfect_square(10)
19
+ False
20
21
+ return math.sqrt(num) * math.sqrt(num) == num
22
23
24
+if __name__ == '__main__':
25
+ import doctest
26
27
+ doctest.testmod()
0 commit comments