-
For all of the data types we have covered this semester, list them as either mutable or immutable.
For each of the following snippets of Python code, give what would be printed to the command line if run. If the snippet will not print anything because of an error, just put error.
-
a_string = "0123456789" for index in range(0, len(a_string), 2): print(a_string[index])
-
a_string = "abcd" for i in range(len(a_string)): print(a_string + a_string)
-
a_string = "abcd" print(a_string[2:4] + a_string[0:2])
-
a_string = "my string!" while(a_string[0] != ' '): a_string = a_string[1:] print(a_string)
-
a_list = [0, 1, 2, 3] b_list = [] index = 0 while index <= len(a_list): b_list.append(a_list[index]) index = index + 1 print(b_list.reverse())
-
def spam(eggs, ham): eggs = eggs + ham eggs = "hello" ham = "world" spam(eggs, ham) print(eggs)
-
def spam(eggs, ham): eggs.append(ham) eggs = ["hello"] ham = "world" spam(eggs, ham) print(eggs)