• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/31

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

31 Cards in this Set

  • Front
  • Back

Accumulator

A variable in a for-loop that stores information computedin the for-loop, which will be still available when the for-loop is complete

Attribute

A variable stored inside an object




Note: It is impossible to enforce invariants on attributes as any value can be stored in an attribute at any time

Bottom-Up Rule

When trying to access a attribute stored inside of an object or use a method stored in a class, it first looks in the object folder, then the object class, then the parent class and so on




Note: If python does not find the attribute or method then it results in an error

Class

A class is a type not built into python, and a value of said type is an object

What goes in the class definition?

class classname(superclass):


Specification


Getters and Setters


Initializer


Methods



Constructor

A function that creates an object for a class




Note: A constructor has the same name as the type of object being created

What happens when a constructor is called?

The constructor:

creates an empty folder,


puts it in heap space,


calls the initializer method,


and returns the object name as the value of the final expression




Default Argument

A value that is given to a parameter if the user does not provide that parameter




Example: foo(x,y=2,z=3)


foo(1,z=4) and foo(1,5) are valid function calls

Dispatch on Type

A function that can take multiple types of input, and its behavior depends on the type of input




Note: Also used in try-excepts to determine whether to recover from an error

Duck Typing

This is a less effective way of determining if an object is a certain type by checking to see if it has attributes and methods of the right names



Note: If it looks like a duck and if it quacks like a duck, then it is a duck

Encapsulation

Hiding data or implementation to prevent them from being accessed by users who do not need them

Getter

This is a method that is used to access a hidden attribute, ensuring that it does not get changed

Global Space

The area of memory that stores any variable not defined in the body of a function




Note: These variables exist until you either erase them manually or quit python

Heap Space

The area of memory that stores mutable objects




Note: The objects can only be accessed directly, via a variable in global space or a call frame with the value of the object name

Immutable Attribute

A hidden attribute that has a getter, but no setter, making it so the user cannot change the attribute

Implementation

The details of a collection of python code that are unimportant to other users of this module or class

What does the implementation include?

The bodies of all functions or methods, hidden functions and hidden methods, and hidden attributes

Inheritence

The process by which a class inherits the attributes and methods of its parent class if the attribute and/or method was not mentioned in the class definition

Interface

The collection of python code that the user sees when they type help(module or class name)

What does the interface include?

A list of the class names, all of the unhidden attributes, and all of the unhidden function or method names with their specifications

Invariant

A statement about an attribute that must always be true




Note: similar to a precondition, the invariant can ensure that certain types of values are not assigned to the attribute

The operator "is"

This is like the operator == except that it compares class names rather than contents

Method

A function stored inside a class folder



Note: A method is called by typing the object name followed by a dot before the function name

Mutable Attribute

A hidden attribute that has both a getter and a setter




Note: the attribute can be changed by the user as long as the invariant is not violated

Object

A value whose type is a class, typically containing attributes and methods

Operator Overloading

The means by which python evaluates the various operator symbols, such as +, *, and /

Overriding a Method

The act of redefining a method previously defined in a parent class




Note: an overridden method is called by typing the name of the super class followed by a dot then the method name

Property

A special way of creating getters and setters, with its value stored in an associated attribute




Note: I don't think we need to know this

Setter

A special method that can change the value of an instance attribute of the same name

Subclass

A class that extends another class




Note: If D is a subclass of C, then D inherits all the attributes and methods from C as well as its own attributes and methods declared in D




Note: Every user defined class must extend another class

Limited Try-Except Statement

A Try-Except statement that only recovers from certain types of errors




Note: It takes the form:


Try:


statements


Except error-class:


statements