100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4.2 TrustPilot
logo-home
Examen

CSC148 Exam with Complete solutions (A Graded)

Puntuación
-
Vendido
-
Páginas
23
Grado
A+
Subido en
07-09-2024
Escrito en
2024/2025

CSC148 Exam with Complete solutions (A Graded)

Institución
CSC148
Grado
CSC148










Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Escuela, estudio y materia

Institución
CSC148
Grado
CSC148

Información del documento

Subido en
7 de septiembre de 2024
Número de páginas
23
Escrito en
2024/2025
Tipo
Examen
Contiene
Preguntas y respuestas

Temas

Vista previa del contenido

CSC148 Exam with Complete solutions (A Graded)
What happens between when the function is executing and when it is finished - ANSWER There
will be a call stack when it is executing. Once it finishes, the call stack is deleted, including the
local variables. The function will finish executing either when it reaches the end of the function
or if it reaches a return statement.


def mess_about(n: int, s: str) -> None:
message = s * n
print(message)


if __name__ == '__main__':
count = 13
word = 'nonsense'
mess_about(count, word)

print(n) - ANSWER name error:n is not defined because there is no return statement in
the function


passing a reference to an immutable object

,like
def emphasize(s: str) -> None:
s = s + s + '!'


if __name__ == '__main__':
word = 'moo'
emphasize(word)

print(word) - ANSWER it will have no effect outside of the funciton because you can't
change an immutable, it will just create a new object


What is special about None - ANSWER we refer to it as both a value and its type.


difference between list and List - ANSWER List is if all are one type list is not as specific



explain class -> instance -> attribute - ANSWER A class is a block of code that defines a type of
data. The built-in Python types that you're familiar with like int, str, and list are all defined by
classes. Suppose we have a class called X. An object whose type is X is called an instance of
class X; for example, the object 3 is an instance of class int.



An instance of a class does not have to contain just a single piece of data as an int does; it can
hold a collection of data bundled together. Each individual piece of data in an instance is
called an instance attribute of the object.



what actually happens when you create a class? like in the tweet example in the readings 2.1 -
ANSWER 1. Create a new Tweet object behind the scenes.

2. Call __init__ with the new object passed to the parameter self, along with the other
three arguments (for who, when, and what).

3. Return the new object. This step is where the object is returned, not directly from the call
to __init__ in Step 2.

, Once we define the Tweet class, how many Tweet objects can we construct? - ANSWER There is
no limit.



tweet.like(10) what does the dot do in this case? - ANSWER we pass one argument, yet the
method has two parameters, self and n. What dot notation does for a method call is
automatically pass the value to the left of the dot (in this case, tweet) as the method's first
parameter self.



difference between class and method - ANSWER Methods are part of the very definition of the
class, and form the basis of how others can use the class. They are bundled together with the
class, and are automatically available to every instance of the class. In contrast, functions that
operate on a class instance must be imported separately before they are used. So it sounds like
functions are "less useful" than methods because you need to do a bit of extra work to use
them.



how do you express that it can be one of two different types when writing a function or
method? - ANSWER Union[int, float] shows that the type of the value can be an int or a float



value could be a certain type, or None, how do we express that - ANSWER Optional[int] which
is equivalent Union[int, None]



Callable[[int, str], bool] what does this mean - ANSWER a type expression for a function
that takes two arguments, an integer and a string, and returns a boolean


write the code that is needed to test the doc strings - ANSWER if __name__ == '__main__':
import doctest # import the doctest library
doctest.testmod()



what is an abstract data type - ANSWER An abstract data type (or ADT) defines some kind of
data and the operations that can be performed on it. It is a pure interface. It is looking primarily
at what data is stored and what can we do with that data
$13.24
Accede al documento completo:

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada


Documento también disponible en un lote

Conoce al vendedor

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.
KenAli West Virginia University
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
84
Miembro desde
1 año
Número de seguidores
5
Documentos
17177
Última venta
1 semana hace

2.9

19 reseñas

5
4
4
4
3
4
2
0
1
7

Recientemente visto por ti

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