How would you write Python code to check whether a number is a perfect square?
Implement is_perfect_square(num) and return True if there is an integer k such that k * k == num; otherwise return False. Avoid floating-point square-root comparisons so the method remains correct for large integers. The input is a nonnegative Python integer, and the output is a Boolean.
num is a Python integer and may exceed fixed-width integer rangesdef is_perfect_square(num):