Python Programming Exam Review Questions With Verified Answers
how do we add a list to a list? - Answer list[2] = [1, 2, 3] how do we ad elements of a list to a list? - Answer list[2:2] = [1,2,3] how do we delete elements from a list? - Answer del list[1] what's another way of deleting elements from a list, besides del? - Answer list[1] = [] what does 3 * [0] return? - Answer [0,0,0] if you really want to copy a list, what can you do? - Answer list2 = list1[:] difference between append and extend? - Answer append adds whole argument as single element, while extend adds each item of argument as element how to insert exactly one element? - Answer t(position, element) what does remove do to a list? - Answer removes first element in list with given value what does () do? - Answer what does () do? - Answer what does () do? - Answer what does (key) return if the key exists? - Answer the value of the key what does (key) return if the key does not exist? - Answer None what kind of objects do dictionary methods return? - Answer view what are the three dictionary methods? - Answer keys(), values(), items() what is the advantage of returning dictionary methods as view objects rather than as lists? - Answer thye are dynamic and reflect changes to the dictionary define list - Answer collection of different objects indexed by numbers what is the big difference between strings and lists? - Answer strings are immutable, lists are mutable what is the difference between list[2] = [1,2,3] and list[2:2] = [1,2,3]? - Answer [2] adds as list, [2:2] adds as separate elements how many elements does list[2:3] represent? - Answer one where does a slice end? - Answer right before the second index of the slice how do you remove element three from a list by slicing? - Answer list[2:3] = [] is len a function or a method? - Answer function how to find the length of a list? - Answer len(list) what do we have to know about the operands of list operators? - Answer both must be lists how to determine whether a value is an element of list? - Answer element in list what does in do? - Answer determines whether element is in list what does in operator return if element is fond? - Answer TRUE what does in return if element is not found? - Answer FALSE how do you return an entire list by slicing? - Answer list[:] how do you reverse the order of elements of a list in place? - Answer se() what are two situations for which tuples can be used but lists cannot? - Answer % formatting, dictionary keys how do you get a dictionary value - Answer dict[key] what are strings? - Answer collection of characters that are stored together what do strings represent? - Answer arbitrary text what are three ways of creating strings from text? - Answer single, double, triple quotes what are two ways to make multiline strings? - Answer triple quotes, backslash backspace - Answer b horizontal tab - Answer t vertical tab - Answer v newline - Answer n bell - Answer a formfeed - Answer f char escape for carriage return - Answer r null terminator - Answer 0 octal escape for ascii - Answer 0nn hex escape for ascii - Answer xnn escape - Answer e what can you put at the beginning of a string when you want escape characters interpreted literally? - Answer r'' what does + do to strings? - Answer concatenate
Escuela, estudio y materia
- Institución
- Python Programming
- Grado
- Python Programming
Información del documento
- Subido en
- 7 de febrero de 2024
- Número de páginas
- 14
- Escrito en
- 2023/2024
- Tipo
- Examen
- Contiene
- Preguntas y respuestas
Temas
-
python programming stuvia
-
python programming exam review questions with veri
-
how do we add a list to a list list2 1 2 3
-
how do we ad elements of a list to a list list2