Question 1. In this question you will practice passing lists as parameters to a function. Your goal is to write a function definition for: SmartSquare (inlist, inplace) . Parameter inlist is a list of integers and the parameter inplace is a boolean with a value True or False.
[30 points] Question 1. In this question you will practice passing lists as parameters to a function. Your goal is to write a function definition for: SmartSquare (inlist, inplace) . Parameter inlist is a list of integers and the parameter inplace is a boolean with a value True or False. The function proceeds as follows: If inplace is True, SmartSquare replaces the numbers in the parameter inlist with their squares. (The list in the calling program will change). The function also returns a list with squares of the numbers of the original list. If inplace is False, SmartSquare returns a list containing the squares of values of the numbers in inlist. The inlist itself is not changed. Here are some sample runs: my list = [2 , 11, 7] sqlist = SmartSquare (mylist, True) print (mylist, sqlist) will print [4, 121, 49] [4, 121, 49] Another run: my list = [2 , 11, 7] sqlist = SmartSquare (mylist, False) print (mylist, sqlist) will print [2, 11, 7] [4, 121, 49]
2 # Define your function here 3 7 # DO NOT CHANGE CODE BELOW 8 mylist = 9 n = int(input("Enter number of elements in the List : ")) 10 for i in range(0, n): 11 val = int(input("Num "+str(i+1))) 12 mylist. append(val) 13 14 print(mylist, SmartSquare(mylist, True)) 15 print(mylist, SmartSquare(mylist, False)) 16