100% Zufriedenheitsgarantie Sofort verfügbar nach Zahlung Sowohl online als auch als PDF Du bist an nichts gebunden 4.2 TrustPilot
logo-home
Prüfung

CSC148 Exam with Complete solutions (A Graded)

Bewertung
-
Verkauft
-
seiten
23
Klasse
A+
Hochgeladen auf
07-09-2024
geschrieben in
2024/2025

CSC148 Exam with Complete solutions (A Graded)

Hochschule
CSC148
Kurs
CSC148










Ups! Dein Dokument kann gerade nicht geladen werden. Versuch es erneut oder kontaktiere den Support.

Schule, Studium & Fach

Hochschule
CSC148
Kurs
CSC148

Dokument Information

Hochgeladen auf
7. september 2024
Anzahl der Seiten
23
geschrieben in
2024/2025
Typ
Prüfung
Enthält
Fragen & Antworten

Themen

Inhaltsvorschau

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
11,64 €
Vollständigen Zugriff auf das Dokument erhalten:

100% Zufriedenheitsgarantie
Sofort verfügbar nach Zahlung
Sowohl online als auch als PDF
Du bist an nichts gebunden


Ebenfalls erhältlich im paket-deal

Lerne den Verkäufer kennen

Seller avatar
Bewertungen des Ansehens basieren auf der Anzahl der Dokumente, die ein Verkäufer gegen eine Gebühr verkauft hat, und den Bewertungen, die er für diese Dokumente erhalten hat. Es gibt drei Stufen: Bronze, Silber und Gold. Je besser das Ansehen eines Verkäufers ist, desto mehr kannst du dich auf die Qualität der Arbeiten verlassen.
KenAli West Virginia University
Folgen Sie müssen sich einloggen, um Studenten oder Kursen zu folgen.
Verkauft
84
Mitglied seit
1 Jahren
Anzahl der Follower
5
Dokumente
17177
Zuletzt verkauft
1 Jahren vor

2,9

19 rezensionen

5
4
4
4
3
4
2
0
1
7

Kürzlich von dir angesehen.

Warum sich Studierende für Stuvia entscheiden

on Mitstudent*innen erstellt, durch Bewertungen verifiziert

Geschrieben von Student*innen, die bestanden haben und bewertet von anderen, die diese Studiendokumente verwendet haben.

Nicht zufrieden? Wähle ein anderes Dokument

Kein Problem! Du kannst direkt ein anderes Dokument wählen, das besser zu dem passt, was du suchst.

Bezahle wie du möchtest, fange sofort an zu lernen

Kein Abonnement, keine Verpflichtungen. Bezahle wie gewohnt per Kreditkarte oder Sofort und lade dein PDF-Dokument sofort herunter.

Student with book image

“Gekauft, heruntergeladen und bestanden. So einfach kann es sein.”

Alisha Student

Häufig gestellte Fragen