Jupiter Please do that squareEachnums function nums is a lis

Jupiter. Please do that
squareEach(nums) function, nums is a list of numbers. The function modifies the list by squaring each entry. The function returns None. Test your solution using the following test() function: def test() nums = list(range(15)) squareEach(nums) print(nums) test() When correctly implemented, the test() function will print [0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196]

Solution

Following is the required code:

def squareEach( nums ):
   for i in range(len(nums)):
       nums[i] = nums[i]*nums[i];
   return None;

def test():
   nums = list( range(15))
   squareEach( nums )
   print( nums);

test();

Jupiter. Please do that squareEach(nums) function, nums is a list of numbers. The function modifies the list by squaring each entry. The function returns None.

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site