• ¿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 1 fuera de 3 páginas
Examen

Comp110 Test Questions with All Correct Answers

Document preview thumbnail
Vista previa 1 fuera de 3 páginas

Comp110 Test Questions with All Correct Answers Which syntax will import the function named powerful from the module named helpers contained in the package named lessons? Choice 1 of 3:import powerful from rsChoice 2 of 3:from rs import powerfulChoice 3 of 3:from powerful import rs - Answer-from rs import powerful For the following examples, you'll be importing the following module named a contained in the package named b: def double(x: int) - int: return x * 2 def double_display(y: int): print(y * 2) double_display(2) if __name__ == "__main__": print(double(3)) Say we defined the module module named c contained in the package named b in the following way: from b.a import double, double_display print(double(1)) double_display(4) What is the output after running python -m b.c? Choice 1 of 5:2, 8 (With commas representing a new line.)Choice 2 of 5:2, 4, 8 (With commas representing a new line.)Choice 3 of 5:4, 2, 8 (With commas representing a new line.)Choice 4 of 5:NoneChoice 5 of 5:Error - Answer-4, 2, 8 You can directly and efficiently lookup a key by its value in a dictionary. True or False - Answer-False Dictionary objects are stored in which part of memory? Choice 1 of 2:stackChoice 2 of 2:heap - Answer-heap True/False - Dictionaries, like lists, are reference types. This means variables assigned dictionaries are actually assigned references to the dictionary. - Answer-True A function can return a reference to a dictionary object. True or False - Answer-True Suppose your test subject(s) (the function(s) you are working on) are contained in a directory named lessons and a file named . Imagine the function you are working on is named example_function. How would you import the function into your tests file? Choice 1 of 2:from cts import example_functionChoice 2 of 2:from lessons/ import example_function - Answer-from cts import example_function Suppose your test functions are contained in a directory named lessons and a file named subjects_. How would you run pytest from the terminal? Choice 1 of 2:python -m pytest cts_testChoice 2 of 2:python -m pytest lessons/subjects_ - Answer-python -m pytest lessons/subjects_ The __str__ method is automatically called when Python attempts to convert an object to a str and the object's class has a __str__ method defined in it. Choice 1 of 2:TrueChoice 2 of 2:False - Answer-True Magic methods are called automatically when certain events occur, such as creating an object or performing arithmetic operations. Choice 1 of 2:TrueChoice 2 of 2:False - Answer-True Suppose you had a class named Fraction representing fractions like 1/2 or 3/4. Further suppose you have two Fraction objects named a and b. If you wrote the expression a + b, Python would look in your class and choose the first method whose first parameter is self and second parameter is of type Fraction. Choice 1 of 2:TrueChoice 2 of 2:False - Answer-False Named constants should be used to store values that may change throughout the program. (T/F) - Answer-False When using a for...in loop, on the first line of the loop you must specify the type of the variable (variable refers to i in for i in nums). - Answer-False Comparing two string values using relational operators always works the way you would expect it to in the English language. T/F? - Answer-False Which operator is used for integer division and results in an int typed value? Choice 1 of 4:/Choice 2 of 4://Choice 3 of 4:%Choice 4 of 4:div - Answer-Choice 2: // The random package has many functions for generating random numbers. There's a random function defined in the random package, you can import and call using a function call expression like so: from random import random random() Try calling the random function many times. What type does a call to the random function evaluate to? Choice 1 of 3:class 'str'Choice 2 of 3:class 'float'Choice 3 of 3:class 'int' - Answer-Choice 2: class 'float'

Vista previa del contenido

Comp110 Test Questions with All
Correct Answers
Which syntax will import the function named powerful from the module named helpers
contained in the package named lessons?
Choice 1 of 3:import powerful from lessons.helpersChoice 2 of 3:from lessons.helpers
import powerfulChoice 3 of 3:from powerful import lessons.helpers - Answer-from
lessons.helpers import powerful

For the following examples, you'll be importing the following module named a contained
in the package named b:
def double(x: int) -> int: return x * 2 def double_display(y: int): print(y * 2)
double_display(2) if __name__ == "__main__": print(double(3))
Say we defined the module module named c contained in the package named b in the
following way:
from b.a import double, double_display print(double(1)) double_display(4)
What is the output after running python -m b.c?
Choice 1 of 5:2, 8 (With commas representing a new line.)Choice 2 of 5:2, 4, 8 (With
commas representing a new line.)Choice 3 of 5:4, 2, 8 (With commas representing a
new line.)Choice 4 of 5:NoneChoice 5 of 5:Error - Answer-4, 2, 8

You can directly and efficiently lookup a key by its value in a dictionary.
True or False - Answer-False

Dictionary objects are stored in which part of memory?
Choice 1 of 2:stackChoice 2 of 2:heap - Answer-heap

True/False - Dictionaries, like lists, are reference types. This means variables assigned
dictionaries are actually assigned references to the dictionary. - Answer-True

A function can return a reference to a dictionary object. True or False - Answer-True

Suppose your test subject(s) (the function(s) you are working on) are contained in a
directory named lessons and a file named subjects.py. Imagine the function you are
working on is named example_function.
How would you import the function into your tests file?
Choice 1 of 2:from lessons.subjects import example_functionChoice 2 of 2:from
lessons/subjects.py import example_function - Answer-from lessons.subjects import
example_function

Información del documento

Subido en
1 de enero de 2025
Número de páginas
3
Escrito en
2024/2025
Tipo
Examen
Contiene
Preguntas y respuestas
$12.59

¿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.
Scholarsstudyguide
3.8
(169)
Vendido
853
Seguidores
476
Artículos
16409
Última venta
2 semanas 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