Starting from:
$30

$24

Exercise #6 Solution

This week, we're working with mutability and the memory model. You will be writing two functions that do almost the same thing, but deal with input/output in very di erent ways. As always your code and testing les should be written in les named ex6.py and ex6.test, and you should not be using any print/input/import statements.




Changing a Copy of a List




Write a function called copy me that takes as input a list, and returns a copy of the list with the following changes:







Strings have all their letters converted to upper-case Integers and oats have their value increased by 1




booleans are negated (False becomes True, True becomes False) Lists are replaced with the word "List"




The function should leave the original input list unchanged (i.e., do not mutate the list)




Mutating a List




Write a function called mutate me that takes as input a list, returns None, and changes the input list in the following ways:







Strings have all their letters converted to upper-case Integers and oats have their value increased by 1




booleans are negated (False becomes True, True becomes False) Lists are replaced with the word "List"




So we're performing the same task, but this time we're changing the list itself instead of making a copy to return.





























































1

More products