第27511题 单选题
下列Python代码中,能够正确且高效地判断输入整数n是否为完全平方数的是?

完全平方数指可以写成某个整数的平方的整数,以下四段Python代码中,逻辑正确且效率合理的是?

A
import math
def is_perfect_square(n):
    return n == math.sqrt(n) ** 2
B
def is_perfect_square(n):
    for i in range(, n+1):
        if i*i ==n:
            return True
    return False
C
def is_perfect_square(n):
    if n < :
        return False
    s = int(n ** .5)
    return s * s == n
D
import math
def is_perfect_square(n):
    return math.sqrt(n).is_integer()
程序运行统计
暂无判题统计
提交0次 正确率0.00%
答案解析