CIS 245 2022/2023 with 100%complete solutions
How would you use string slicing [:] to print out 'qua' from the following string? x = 'From ' Answer choices: x[9:12] x['qua'] x[8:11] x[8:10] x[8:11] What does the following Python code print out? print 3*len('python') Answer choices: 18 15 '3python' 'pythonpythonpython' 18 00:00 01:28 What will the following Python code print out? x = 'ContentType: text/plain; charset=UTF8' search = 'charset=' pos = (search) c = x[pos+len(search):] print c Answer choices: UTF8 charset=UTF8 text/plain UTF UTF - 8 Which of the following string methods removes whitespace from both the beginning and end of a string? Answer choices: lower() strip() trim() remspace() strip() What is returned from a successful open() call? Answer choices: A list of all the files in a particular folder on the hard drive The entire contents of the file in a string The first line of the file in a string A file handle which connects to the file's data A file handle which connects to the file's data How do we open a file for writing? Answer choices: Call setwritemode() on the file handle Pass 'w' as the second parameter to open() Pass 'write' as the first parameter to open() Call open_for_write() and pass in the file path Pass 'w' as the second parameter to open() What does 'n' indicate in a string? Answer choices: The NULL character Two 'n' characters in a row The position in the string where new data will be written The end of one line of text and the beginning of another line of text The end of one line of text and the beginning of another line of text If we open a file as follows: xfile = open('') What statement would we use to read the file one line at a time? Answer choices: while xfile: iterate_lines() for line in xfile: while line = ine(): for line in xfile: What is the purpose of the following Python code? fhand = open('') x = 0 for line in fhand: x = x + 1 print line if x >= 10: break Answer choices: Skip the first 10 lines of and print the remaining lines Count the lines in Create a new file from the first 10 lines of Print out the first 10 lines in Print out the first 10 lines in What does the following Python code do? f = open('') s = () Answer choices: Reads the entire contents of into s as a string Writes the string 's' to Reads the first line of into s as a string Sets s to a file handle in read mode Reads the entire contents of into s as a string
Escuela, estudio y materia
- Institución
- CIS 245
- Grado
- CIS 245
Información del documento
- Subido en
- 19 de marzo de 2023
- Número de páginas
- 18
- Escrito en
- 2022/2023
- Tipo
- Examen
- Contiene
- Preguntas y respuestas
Temas
-
cis 245 20222023 with 100complete solutions
Documento también disponible en un lote