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
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
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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F3b25bdcc-1f5e-4716-88d3-d1e15ee2df25%2F18525f3f-34db-4278-8824-f7e5a7e650d8%2F48wl9kg_processed.png&w=3840&q=75)
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
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)