Count the Perfect Squares

Python for AIMedium+10 XP+10

Count the Perfect Squares

A perfect square is a whole number you get by multiplying a whole number by itself: 0, 1, 4, 9, 16, 25, ...

Write count_perfect_squares(numbers) that returns how many numbers in the list are perfect squares.

  • Every number is a whole number, 0 or bigger.
  • 0 counts (it's 0 × 0).
  • Duplicates each count separately.
  • An empty list gives 0.

Use math.sqrt and math.floor. math.floor rounds a number down to the whole number below it.

Examples

numbers = [1, 2, 4, 9, 10]
returns 3
numbers = [2, 3, 5]
returns 0

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run