Prompt Engineering 2
No description yet. This curated deck is ready for daily study.
Card preview (24)
What are the two core elements contained within a class definition? / Was sind die zwei Kernelemente, die in einer Klassendefinition enthalten sind?
Data (stored via attributes) and Behavior (implemented via methods). / Daten (gespeichert über Attribute) und Verhalten (implementiert über Methoden).
What is an instance of a class? / Was ist eine Instanz einer Klasse?
A concrete object created from a class blueprint that possesses its own isolated state. / Ein konkretes Objekt, das aus dem Bauplan einer Klasse erstellt wurde und einen eigenen, isolierten Zustand besitzt.
What does ‘self’ represent inside a Python class method? / Was repräsentiert ‘self’ innerhalb einer Python-Klassenmethode?
It points directly to the current unique object instance on which the method is being called. / Es verweist direkt auf die aktuelle, spezifische Objektinstanz, auf der die Methode aufgerufen wird.
What is the primary responsibility of the __init__ constructor method? / Was ist die Hauptaufgabe der __init__-Konstruktormethode?
To initialize an instance and establish a valid baseline starting state (invariants). / Eine Instanz zu initialisieren und einen gültigen Ausgangszustand (Invarianten) herzustellen.
What is a class invariant? / Was ist eine Klasseninvariante?
A structural condition or business rule that must always remain true and valid throughout the entire lifetime of an object. / Eine strukturelle Bedingung oder Geschäftsregel, die über die gesamte Lebensdauer eines Objekts hinweg immer wahr und gültig bleiben muss.
What is the difference between an instance attribute and a class attribute? / Was ist der Unterschied zwischen einem Instanzattribut und einem Klassenattribut?
Instance attributes are separate for every unique object; class attributes are shared globally across all instances of that class. / Instanzattribute sind für jedes Objekt separat; Klassenattribute werden global von allen Instanzen dieser Klasse geteilt.
How are private attributes indicated by convention in Python naming? / Wie werden private Attribute laut Konvention in der Python-Namensgebung gekennzeichnet?
By prefixing the attribute name with a single underscore (e.g., self._balance). / Indem dem Attributnamen ein einzelner Unterstrich vorangestellt wird (z. B. self._balance).
What is the purpose of the @property decorator? / Was ist der Zweck des @property-Decorators?
It exposes a method as a read-only virtual attribute, allowing clean access without parentheses. / Er macht eine Methode als schreibgeschütztes, virtuelles Attribut verfügbar, was einen sauberen Zugriff ohne Klammern ermöglicht.
What target audience is the __str__ magic method intended for? / Für welche Zielgruppe ist die magische Methode __str__ gedacht?
End users; it provides a readable, user-friendly textual representation of the object. / Endbenutzer; sie liefert eine gut lesbare, benutzerfreundliche Textdarstellung des Objekts.
What target audience is the __repr__ magic method intended for? / Für welche Zielgruppe ist die magische Methode __repr__ gedacht?
Developers; it provides an unambiguous text representation ideally suited for debugging and logging. / Entwickler; sie liefert eine eindeutige Textdarstellung, die sich ideal für Debugging und Logging eignet.
What utility decorator automatically generates boilerplate constructor, string, and comparison methods? / Welcher Utility-Decorator generiert automatisch Standardcode für Konstruktoren, Strings und Vergleichsmethoden?
The @dataclass decorator from the dataclasses module. / Der @dataclass-Decorator aus dem dataclasses-Modul.
Why should mutable default arguments (like lists) be avoided in standard constructor parameters? / Warum sollten veränderliche Standardargumente (wie Listen) in Standard-Konstruktorparametern vermieden werden?
They are evaluated once at definition time and shared across all instances, causing accidental data cross-contamination. / Sie werden nur einmal zur Definitionszeit ausgewertet und von allen Instanzen geteilt, was zu versehentlichen Datenüberschneidungen führt.
What design principle suggests that a class should encapsulate data and expose only necessary control methods? / Welches Designprinzip besagt, dass eine Klasse Daten kapseln und nur notwendige Kontrollmethoden offenlegen sollte?
Information Hiding or Encapsulation. / Geheimnisprinzip oder Kapselung.
What is the naming convention for Python classes? / Wie lautet die Namenskonvention für Python-Klassen?
PascalCase (e.g., BankAccount). / PascalCase (z. B. BankAccount).
What is the naming convention for Python attributes and methods? / Wie lautet die Namenskonvention für Python-Attribute und -Methoden?
snake_case (e.g., calculate_balance). / snake_case (z. B. calculate_balance).
What is Polymorphism in object-oriented programming? / Was ist Polymorphie in der objektorientierten Programmierung?
The ability to trigger the exact same method call on different objects and have each object execute its own specific behavior. / Die Fähigkeit, denselben Methodenaufruf auf verschiedenen Objekten auszuführen, wobei jedes Objekt sein eigenes, spezifisches Verhalten zeigt.
What is the core philosophy of ‘Duck Typing’ in Python? / Was ist die Kernphilosophie von ‘Duck Typing’ in Python?
‘If it walks like a duck and quacks like a duck, it is a duck’—behavior and methods matter, not the explicit class inheritance. / ‘Wenn es wie eine Ente läuft und quakt, ist es eine Ente’—das Verhalten und die Methoden zählen, nicht die explizite Klassenzugehörigkeit.
What is a Protocol in Python and what type of checking does it provide? / Was ist ein Protocol in Python und welche Art von Prüfung bietet es?
A structural interface definition used for static type checking (compile-time) without forcing class inheritance. / Eine strukturelle Schnittstellendefinition für die statische Typprüfung (Zur Compile-Zeit) ohne Vererbungszwang.
What does ABC stand for and what is its purpose? / Wofür steht ABC und was ist ihr Zweck?
Abstract Base Class; a runtime interface enforcement mechanism that prevents instantiation if abstract methods are missing. / Abstract Base Class; ein Mechanismus zur Laufzeit-Schnittstellenprüfung, der die Instanziierung verhindert, wenn abstrakte Methoden fehlen.
What decorator must be used to declare a method abstract inside an ABC? / Welcher Decorator muss verwendet werden, um eine Methode innerhalb einer ABC als abstrakt zu deklarieren?
The @abstractmethod decorator from the abc module. / Der @abstractmethod-Decorator aus dem abc-Modul.
What is the difference between explicit inheritance and structural typing (Protocols)? / Was ist der Unterschied zwischen expliziter Vererbung und struktureller Typisierung (Protocols)?
Inheritance requires nominal subclassing (is-a relationship); Protocols check if matching methods exist regardless of lineage. / Vererbung erfordert nominale Unterklassenbildung (ist-ein-Beziehung); Protocols prüfen das Vorhandensein passender Methoden unabhängig von der Abstammung.
What is the function of super() inside an overridden method? / Welche Funktion hat super() innerhalb einer überschriebenen Methode?
It delegates the method call to the next class in line according to the Method Resolution Order (MRO). / Es delegiert den Methodenaufruf an die nächste Klasse gemäss der Method Resolution Order (MRO).
What does MRO stand for in Python inheritance hierarchies? / Wofür steht MRO in Python-Vererbungshierarchien?
Method Resolution Order; the deterministic path Python follows to look up attributes and methods. / Method Resolution Order; der deterministische Pfad, dem Python folgt, um Attribute und Methoden nachzuschlagen.
What attribute can you inspect on a class to see its exact MRO sequence? / Welches Attribut kann man auf einer Klasse inspizieren, um ihre genaue MRO-Reihenfolge zu sehen?
The __mro__ attribute (or calling the .mro() method). / Das __mro__-Attribut (oder der Aufruf der .mro()-Methode).