In our implementation of the scale function (page 25), the body of the loop executes the command data[j] = factor. We have discussed that numeric types are immutable, and that use of the = operator in...

In our implementation of the scale function (page 25), the body of the loop

executes the command data[j] = factor. We have discussed that numeric


types are immutable, and that use of the = operator in this context causes


the creation of a new instance (not the mutation of an existing instance).


How is it still possible, then, that our implementation of scale changes the


actual parameter sent by the caller?



Q148: Had we implemented the scale function (page 25) as follows, does it work


properly?


def scale(data, factor):


for val in data:


val = factor


Explain why or why not.




May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here