Write a function squares that accepts a 2-dimensional list of integers or a list of ranges as an input, and that returns the count of all the integers that are perfect squares. ⚫ a perfect square is an integer that is the square of another integer. 9 is a perfect square because 9 is equal to 3 squared. ⚫ don't worry about the ranges, if you write your code in the obvious way, it will also work for ranges. Sample usage: >>> squares [[1,2,3], [4,5], [6,7,8,9]]) #23 1,4,9 are perfect squares 3 >>> squares [[1,2,3], [4,5,6],[7,8], [9, 10, 11, 12], [13,14,15,16]] ) 4 >>> squares( [ range (1,1000,7), range(1,500,13)]) 12 >>> squares( [range (2,1000,3), range (7,100,8), range (8,1000, 5)]) 0 >>> squares( [ range (1,1000,7), range(1,500,13)])==12 True

icon
Related questions
Question
Write a function squares that accepts a 2-dimensional list of integers or a list of ranges as an
input, and that returns the count of all the integers that are perfect squares.
⚫ a perfect square is an integer that is the square of another integer. 9 is a perfect square
because 9 is equal to 3 squared.
⚫ don't worry about the ranges, if you write your code in the obvious way, it will also work for
ranges.
Sample usage:
>>> squares [[1,2,3], [4,5], [6,7,8,9]]) #23 1,4,9 are perfect squares
3
>>> squares [[1,2,3], [4,5,6],[7,8], [9, 10, 11, 12], [13,14,15,16]] )
4
>>> squares( [ range (1,1000,7), range(1,500,13)])
12
>>> squares( [range (2,1000,3), range (7,100,8), range (8,1000, 5)])
0
>>> squares( [ range (1,1000,7), range(1,500,13)])==12
True
Transcribed Image Text:Write a function squares that accepts a 2-dimensional list of integers or a list of ranges as an input, and that returns the count of all the integers that are perfect squares. ⚫ a perfect square is an integer that is the square of another integer. 9 is a perfect square because 9 is equal to 3 squared. ⚫ don't worry about the ranges, if you write your code in the obvious way, it will also work for ranges. Sample usage: >>> squares [[1,2,3], [4,5], [6,7,8,9]]) #23 1,4,9 are perfect squares 3 >>> squares [[1,2,3], [4,5,6],[7,8], [9, 10, 11, 12], [13,14,15,16]] ) 4 >>> squares( [ range (1,1000,7), range(1,500,13)]) 12 >>> squares( [range (2,1000,3), range (7,100,8), range (8,1000, 5)]) 0 >>> squares( [ range (1,1000,7), range(1,500,13)])==12 True
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Similar questions