Language Design and Abstrations
Object-Oriented Design
Copying in Python
Python Inheritance & Typing
100

This architecture is the first instance of a stored-program digital computer

von Nuemann architecture 

100

What is used to define a function in Python?

The def keyword.

100

What is the syntax for a shallow vs a deep copy in Python?

copy.copy() - shallow

copy.deepcopy() - deep

100

What is the syntax for creating a subclass that inherits from multiple superclasses in Python

class Subclass(SuperClass1, SuperClass2):

200

This term refers to simplifying the behavior and attributes of data for humans in programming

data abstration

200

What is the main difference between instance variables and class variables?

Instance variables are unique to each object, while class variables are shared by all instances.

200

What is the difference between a deep copy and a shallow copy?

A shallow copy references the original object, while a deep copy creates new instances of all objects recursively 

200

How does Python resolve method calls when a class inherits from multiple superclasses

Python uses the method resolution order (MRO) to determine which method to call

300

Name one computational paradigm besides imperative programming

functional programming 

logic

scripting

object-oriented

300

How do you add a method or variable to a class or instance “on the fly” in Python?

You can add methods or variables by defining them outside the class and binding them to the object or class instance.

300

Why are deep and shallow copies only relevant for compound objects in Python?

Compound objects contain other objects, and copying behavior can differ based on whether you copy references or create entirely new objects. 

300

How does Python's dynamic typing work

Types are determined at runtime, allowing variables to hold objects of different types during their lifetime

400

A program that translates high-level code into machine code at run time

an interpreter

400

What is a constructor, and what does it do in Python classes?

A constructor, defined by __init__, sets instance variables when creating an object.

400

Explain the difference in how a shallow copy and a deep copy would affect a list that contains other lists

A shallow copy would copy references to the inner lists, while a deep copy would recursively copy each list, making completely independent inner lists

400

How does dynamic binding work in Python

Method calls are resolved at runtime based on the actual type of the object

500

These two types of programming language abstractions simplify control and data for the programmer 

control abstraction and data abstractions 

500

What is the deadly diamond of death in multiple inheritance?

It’s an issue where a class inherits from two classes that both inherit from the same base class, leading to ambiguity in method resolution.

500

How does Python prevent the deadly diamond of death in multiple inheritance scenarios

Python uses the C3 linearization algorithm (MRO) to ensure a consistent method resolution order