String Lists 1 / 50What is a nested list? A list inside a dictionary A list inside another list A list with no elements A list of strings 2 / 50What is the output of max([1, 10, 5])? 1 5 10 None 3 / 50Which operator checks if an item is NOT in a list? not in is not ! none 4 / 50What happens if you try to access L[10] on a list of length 5? Returns None Returns 0 Raises IndexError Wraps around to the start 5 / 50What is the result of [x for x in range(3)]? [0, 1, 2] [1, 2, 3] [0, 1, 2, 3] Error 6 / 50How do you copy a list ‘L’ into ‘L2’? L2 = L L2 = L.copy() L2 = L[:] Both B and C 7 / 50What is the output of 2 in [1, 2, 3]? True False 1 Error 8 / 50How do you clear all elements from list ‘L’? L.remove_all() L.clear() del L L = empty 9 / 50What is the output of [1, 5, 2].reverse()? [2, 5, 1] None [1, 2, 5] Error 10 / 50Which function returns a sorted copy of a list without modifying the original? sort() sorted() order() copy_sort() 11 / 50What is the result of list(‘abc’)? ['a', 'b', 'c'] ['abc'] ('a', 'b', 'c') Error 12 / 50How do you find the index of ‘blue’ in [‘red’, ‘blue’, ‘green’]? L.find('blue') L.index('blue') L.search('blue') L['blue'] 13 / 50Are lists in Python mutable? Yes No Only if they contain numbers Only if empty 14 / 50What is the output of [1, 2, 3][1:2]? [2] [1, 2] [2, 3] [] 15 / 50How do you remove a specific value ‘val’ from list ‘L’? L.pop('val') L.remove('val') L.delete('val') del L['val'] 16 / 50What does L.extend([4, 5]) do to L = [1, 2]? L becomes [1, 2, [4, 5]] L becomes [1, 2, 4, 5] Returns [1, 2, 4, 5] L stays [1, 2] 17 / 50Which method sorts a list in-place? sorted() sort() arrange() order() 18 / 50What is the result of [1, 2, 3] * 2? [1, 2, 3, 1, 2, 3] [2, 4, 6] [1, 1, 2, 2, 3, 3] Error 19 / 50How do you insert ‘x’ at index 1 in list ‘L’? L.add(1, 'x') L.insert(1, 'x') L[1] = 'x' L.append(1, 'x') 20 / 50What is the output of len([10, 20, 30])? 2 3 4 30 21 / 50Which method removes and returns the last element of a list? remove() pop() delete() discard() 22 / 50How do you access the first element of list ‘L’? L[1] L[0] L.first() L{0} 23 / 50What is the result of [1, 2] + [3, 4]? [1, 2, 3, 4] [[1, 2], [3, 4]] [4, 6] Error 24 / 50Which method adds an element to the end of a list? add() append() extend() insert() 25 / 50How do you create an empty list? [] list() Both A and B None of these 26 / 50Which method returns the title cased version of a string? title() capitalize() toTitle() upper() 27 / 50What is the result of ‘Data’.index(‘a’, 2)? 1 2 3 Error 28 / 50How to check if a string starts with ‘He’? s.start('He') s.startswith('He') s[0:1] == 'He' s.has('He') 29 / 50What is the output of ‘count’.count(‘t’)? 0 1 2 3 30 / 50Which slice returns the whole string ‘s’ reversed? s[0:-1] s[::-1] s[-1:0] s[rev] 31 / 50What does ‘ ‘.isspace() return? True False None Error 32 / 50What is the output of ‘test’ == ‘TEST’? True False None Error 33 / 50How do you find the index of the first ‘o’ in ‘banana’? 'banana'.find('o') 'banana'.index('a') Both return -1 find returns -1, index raises Error 34 / 50What does ‘123’.isdigit() return? True False 123 None 35 / 50What is the result of ‘hello’.capitalize()? Hello HELLO hello hELLO 36 / 50Which function converts a list of strings into one string? combine() join() merge() concat() 37 / 50What is the output of ‘Python’.lower()? python PYTHON Python PyThOn 38 / 50How do you get the last character of string ‘s’? s[last] s[-1] s[len(s)] s.end() 39 / 50What is the result of ‘1,2,3’.split(‘,’)? ['1', '2', '3'] (1, 2, 3) 123 ['1,2,3'] 40 / 50Which method replaces a substring with another? change() replace() switch() update() 41 / 50What is the output of ‘apple’.find(‘p’)? 0 1 2 -1 42 / 50Strings in Python are mutable. True False Only if declared as var Depends on version 43 / 50How do you check if ‘a’ is in string ‘s’? s.contains('a') if 'a' in s: s.find('a') s.has('a') 44 / 50What does ‘Python’ * 2 produce? PythonPython Python 2 Error Python^2 45 / 50Which method removes whitespace from both ends of a string? clean() strip() trim() remove() 46 / 50What is the output of ‘hello'[1:4]? ell hell ello el 47 / 50How do you get the length of a string ‘s’? s.length() len(s) length(s) s.size() 48 / 50What is the result of ‘abc’ + ‘def’? abcdef abc def abc+def Error 49 / 50Which method converts a string to all uppercase? toupper() upper() uppercase() toUpper() 50 / 50What is the output of print(‘Python'[1])? P y t h Your score isThe average score is 0%