• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 4 fuera de 44 páginas
Examen

Cs 1110 Final Exam Complete Exam Questions, Answer Key & Python Worked Solutions Fall 2026 Cornell University Introduction To Computing Using Python

Document preview thumbnail
Vista previa 4 fuera de 44 páginas

A full set of CS 1110 final exam questions with an answer key and rationales for each one, built around Cornell's Introduction to Computing Using Python course. It covers control flow, functions, data structures, recursion, object-oriented programming, testing and file handling. Work through the questions and explanations to trace code, check your reasoning, and get ready for the exam.

Vista previa del contenido

2026
A+ VERIFIED

CS 1110 Final Exam Complete Exam Questions, Answer Key & Python
Worked Solutions Fall 2026/2027 Updated 100% Correct - Cornell
University. 245 Questions
Clinical | Rationale-Driven - Pass Guaranteed - A+ Graded




245 1 245
QUESTIONS SECTIONS RATIONALES




WHAT THIS COVERS


01 Computer Science / Introduction to Computing Using Python


02 Control flow


03 Functions


04 Data structures


05 Recursion


06 Object-oriented programming




ABOUT THIS ASSESSMENT
This final exam assesses mastery of Python fundamentals, control flow, functions, data structures, recursion, object-oriented
programming, testing, file handling, and algorithmic problem solving at the level of Cornell CS 1110 (Fall 2026/2027). Questions
require multi-step reasoning, code tracing, and synthesis across concepts.

, EXAMINATION QUESTIONS



SECTION 1 - Computer Science / Introduction to Computing Using Python (Questions 1
to 245)

1. What is the output of: print('Hello'[::-1])?
A. 'olleH'
B. 'Hello'
C. 'H'
D. 'o'
Answer: A [Concept: Computer Science / Introduction to Computing Using Python]
Rationale: The slice [::-1] reverses the string, yielding 'olleH'. Other options are original string or single characters.

2. A recursive function lacks a base case for n<0; what happens when called with n=-1?
A. It returns 0 immediately.
B. It raises RecursionError after exceeding the recursion limit.
C. It raises ValueError because n is negative.
D. It returns None.
Answer: B [Concept: Computer Science / Introduction to Computing Using Python]
Rationale: Without a base case, the recursive calls never terminate, so Python raises RecursionError once the call stack exceeds the
limit (default ~1000). Python does not automatically return 0 or None for negative inputs, and no ValueError is raised.

3. In a class, what does the __init__ method's first parameter typically represent?
A. The class itself
B. The newly created instance
C. A module-level variable
D. A temporary placeholder
Answer: B [Concept: Computer Science / Introduction to Computing Using Python]
Rationale: __init__ is an instance method; its first parameter (conventionally self) refers to the instance being initialized. Option A
describes class methods; C and D are unrelated.

4. What does the following print? with open('f.txt','w') as f: f.write('hi'); print(f.closed)
A. True
B. False
C. None
D. Error
Answer: A [Concept: Computer Science / Introduction to Computing Using Python]
Rationale: The with statement closes the file upon exiting the block, so f.closed is True. Option B would be true inside the block
before exit; C and D are incorrect.

5. For `def g(L): L.append(1); return L`, what does `g([]) is g([])` evaluate to?
A. True
B. False
C. TypeError
D. None
Answer: B [Concept: Computer Science / Introduction to Computing Using Python]
Rationale: Each call creates a distinct list object, so identity comparison is False. A confuses equality with identity; C and D are
incorrect.




Page 2 | CS 1110 Final Exam Complete Exam Questions, Answer Key & Python Worked Solutions Fall 2026/2027 Updated 100% Correct - Cornell

, 6. How many times does `for i in range(2, 10, 3):` iterate?
A. 2
B. 3
C. 4
D. 8
Answer: B [Concept: Computer Science / Introduction to Computing Using Python]
Rationale: range(2, 10, 3) yields 2, 5, and 8-three values-before reaching or exceeding the stop value 10. Option A omits the last value
;
C miscomputes the count; D is the span of the range, not the number of elements.

7. After `f=open('t.txt','w'); f.write('ab'); f.close()`, what does `open('t.txt').read()` return?
A. 'ab'
B. ''
C. 2
D. IOError
Answer: A [Concept: Computer Science / Introduction to Computing Using Python]
Rationale: Writing 'ab' then closing flushes the buffer; reading returns 'ab'. B would occur without close/flush, C confuses return value
of write, D is not raised.

8. In Python, which statement about default mutable arguments is correct?
A. Defaults are re-evaluated on every call.
B. Defaults are evaluated once at function definition.
C. Mutable defaults are prohibited by the interpreter.
D. Defaults are copied deeply for each call.
Answer: B [Concept: Computer Science / Introduction to Computing Using Python]
Rationale: Python evaluates default expressions once when the def executes, so a mutable default persists across calls. Re-evaluation
per call is false. Mutable defaults are legal, though discouraged. Deep copying never occurs automatically.

9. What is the output of: print(1 < 2 < 3)?
A. True
B. False
C. Error
D. None
Answer: A [Concept: Computer Science / Introduction to Computing Using Python]
Rationale: Python supports chained comparisons: 1 < 2 < 3 is equivalent to (1 < 2) and (2 < 3), both True, so overall True. No error
occurs.

10. Which expression yields the number of distinct words in `s` (case-sensitive, whitespace-split)?
A. `len(s.split())`
B. `len(set(s.split()))`
C. `len(s.split(' '))`
D. `sum(1 for w in s.split() if w)`
Answer: B [Concept: Computer Science / Introduction to Computing Using Python]
Rationale: `set(s.split())` removes duplicate tokens, so its length counts distinct words. A counts all tokens including repeats; C splits
only on single spaces and mishandles multiple whitespace; D counts non-empty tokens, not distinct ones.

11. With open('data.txt') as f, which reads the entire file into one string?
A. f.read()
B. f.readline()
C. f.readlines()
D. list(f)
Answer: A [Concept: Computer Science / Introduction to Computing Using Python]
Rationale: f.read() returns the whole remaining file as a single str. readline() returns one line, readlines() returns a list of lines, and
list(f) returns a list of line strings - none is a single string.




Page 3 | CS 1110 Final Exam Complete Exam Questions, Answer Key & Python Worked Solutions Fall 2026/2027 Updated 100% Correct - Cornell

, 12. Which assertion about `is` versus `==` for small ints and interned strings is correct?
A. `is` compares values; `==` compares identity.
B. `a = 256; b = 256; a is b` is guaranteed True due to CPython caching.
C. `'ab' is 'ab'` is guaranteed False because strings are always new objects.
D. `[] is []` is True because empty lists share a singleton.
Answer: B [Concept: Computer Science / Introduction to Computing Using Python]
Rationale: CPython caches small integers in [-5, 256], so `256 is 256` is True in practice (an implementation detail, not language
guarantee). `is` checks identity, not value; string interning is implementation-specific, and empty lists are distinct objects.

13. Which statement about Python's pass-by-assignment (call-by-object) semantics is correct?
A. Integers are passed by reference, so modifying a parameter changes the caller's variable.
B. Lists are passed by value, so appending inside a function never affects the caller.
C. Parameters are local names bound to the same objects; mutating a mutable argument is visible to the caller.
D. Assignment inside a function always rebinds the caller's variable.
Answer: C [Concept: Computer Science / Introduction to Computing Using Python]
Rationale: Python binds parameter names to the same objects, so mutating a mutable object (e.g., list.append) affects the caller, but
rebinding the parameter does not. Integers are immutable and lists are not copied on call.

14. In `def outer(): x=1; def inner(): nonlocal x; x+=1; return inner`, what does the returned function do?
A. Raises UnboundLocalError on first call.
B. Creates a new local x each call, always returning 2.
C. Increments the enclosing x, returning 2 then 3 on successive calls.
D. Modifies a global x, leaving outer's x unchanged.
Answer: C [Concept: Computer Science / Introduction to Computing Using Python]
Rationale: `nonlocal x` binds to the enclosing scope's x, so successive calls mutate the same cell, returning 2 then 3. A confuses
nonlocal with local, B ignores the closure, and D confuses nonlocal with global.

15. Given class P with method speak returning 'P', and class C(P) overriding speak to return 'C' plus super().speak(),
what does C().speak() return?
A. 'C'
B. 'P'
C. 'CP'
D. TypeError
Answer: C [Concept: Computer Science / Introduction to Computing Using Python]
Rationale: C.speak concatenates its own 'C' with super().speak(), which resolves to P.speak and returns 'P', producing 'CP'. Option A
omits the super call; B ignores the override.

16. Which best explains why `[[]]*3` differs from `[[] for _ in range(3)]`?
A. List multiplication copies inner lists; comprehension does not.
B. Both create three distinct inner lists; only identity differs.
C. Multiplication repeats the same inner list reference; comprehension creates new lists.
D. Comprehension shares references; multiplication creates independent lists.
Answer: C [Concept: Computer Science / Introduction to Computing Using Python]
Rationale: Sequence repetition duplicates references to the same object, so all three outer elements alias one inner list; mutating one
affects all. A list comprehension evaluates `[]` anew each iteration, producing three independent lists. The other options invert or
misstate this aliasing behavior.

17. Which code correctly writes lines to a file and guarantees closure even on error?
A. f=open('o.txt','w'); f.write('a')
B. with open('o.txt','w') as f: f.write('a\n')
C. open('o.txt','w').write('a')
D. f=open('o.txt'); f.write('a'); f.close()
Answer: B [Concept: Computer Science / Introduction to Computing Using Python]
Rationale: The `with` statement ensures the file is closed even if an exception occurs. Option A never closes the file. Option C closes
only via garbage collection and is unreliable. Option D opens in read mode, so write raises io.UnsupportedOperation.




Page 4 | CS 1110 Final Exam Complete Exam Questions, Answer Key & Python Worked Solutions Fall 2026/2027 Updated 100% Correct - Cornell

Información del documento

Subido en
16 de noviembre de 2026
Número de páginas
44
Escrito en
2026/2027
Tipo
Examen
Contiene
Preguntas y respuestas
$30.99

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
PremiumExamBank
4.8
(1071)
Vendido
523
Seguidores
78
Artículos
10577
Última venta
1 día hace



Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes