Question: Create these functions in list _ functions.py . Write a function squares ( n ) that returns a list of all the perfect squares from

Create these functions in list_functions.py.Write a function squares(n) that returns a list of all the perfect squares from 1 to n2. So, squares(5) should build the list [1,4,9,16,25], and return it. In your function, start with an empty list ([]) and use the .append method in a loop to add successive squares to the list.Create a function even_only that takes a list of numbers as an argument. It should return a list that consists of all the elements from the argument that are even numbers. For example, even_only([2,4,5,9,10,12]) should return [2,4,10,12] and even_only(squares(10)) should return [4,16,36,64,100].Suggestion: Create an empty list for the result. Iterate though the items in the argument list. As you go, if an item is even, add it to the result list. At the end, return the result list.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!