Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Document preview thumbnail
Vista previa 2 fuera de 8 páginas
Examen

WMU CS2 Final Ques &ANSW

Document preview thumbnail
Vista previa 2 fuera de 8 páginas

WMU CS2 Final Ques &ANSW Which would be the base case in a recursive solution to the problem of finding the factorial of a number. Recall that the factorial of a non-negative whole number is defined as n! where:

Vista previa del contenido

WMU CS2 Final Ques &ANSW

Which would be the base case in a recursive solution to the problem of finding the
factorial of a number. Recall that the factorial of a non-negative whole number is defined
as n! where:
If n = 0, then n! = 1
If n > 0, then n! = 1 x 2 x 3 x ... x n - ANSW n = 0

The os Module's remove and rename functions delete a file and specify a new name for
a file, respectively. - ANSW True

__________ has the ability to define a method in a subclass and then define a method
with the same name in a superclass. - ANSW Polymorphism

What will the following program display?
def main():my_string = 'One, two, three, four'
word_list = my_string.split()
print(word_list)
main() - ANSW ['One,', 'two,', 'three,', 'four']

Which would you use to delete an existing key-value pair from a dictionary? - ANSW
del

A function is called from the main function for the first time and then calls itself seven
times. What is the depth of recursion? - ANSW 7

What will the following program display?
def main():print(test2(18, 5))def test2(x, y):if x < y:return -5else:return (test2(x-y, y+5) +
6)main() - ANSW 7

The base case is the case in which the problem can be solved without - ANSW
recursion

What is the number of the first index in a dictionary? - ANSW Dictionaries are not
indexed by number.

Converting objects to JSON text format known as serializing - ANSW True

If you try to retrieve a value from a dictionary using a nonexistent key, a KeyError
exception is raised. - ANSW True

What will the following program display?
class Test:
def __init__(self):

, self.num1 = 0class
Derived_Test(Test):
def __init__(self):
self.num2 = 1def
main():
show = Derived_Test()
print(show.num1,show.num2)
main() - ANSW Error because class Derived_Test inherits Test but variable num1 isn't
inherited

Combining data and code in a single object is known as - ANSW encapsulation

Which of the following will create an object, worker_joey, of the Worker class? - ANSW
worker_joey = Worker()

Invalid indexes do not cause slicing expressions to raise an exception - ANSW
Question options:
True

A mutator method has no control over the way that a class's data attributes are
modified. - ANSW False

In a UML diagram the first section holds the list of the class's methods. - ANSW False

What will be displayed after the following code executes?
mystr = 'yes'
yourstr = 'no'
mystr += yourstr * 2
print(mystr) - ANSW yesnono

If the start index is __________ the end index, the slicing expression will return an
empty string. - ANSW greater than

What type of method provides a safe way for code outside a class to retrieve the values
of attributes, without exposing the attributes in a way that could allow them to be
changed by code outside the method? - ANSW accessor

When an object is passed as an argument, __________ is passed into the parameter
variable. - ANSW a reference to the object

Which section in the UML holds the list of the class's methods? - ANSW third section

What is the correct structure to create a dictionary of months where each month will be
accessed by its month number (for example, January is month 1, April is month 4)? -
ANSW { 1 : 'January', 2 : 'February', ... 12 : 'December' }

Información del documento

Subido en
14 de noviembre de 2023
Número de páginas
8
Escrito en
2023/2024
Tipo
Examen
Contiene
Preguntas y respuestas
$10.49

¿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

Vendido
3
Seguidores
1
Artículos
327
Última venta
5 meses 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