🐍

Python: Built-in Functions

77 cards · 🇺🇸 English

Core built-in functions every Python developer should know.

Study all 77 cards for free

Flashcards, quizzes, pixel-art games and a daily review that remembers for you.

Study this deck free

Try the first 10 cards

1 / 10
Question

Abs()

Knew itLearning

Tap the card for the answer · swipe right if you knew it, left if not

Already have an account? Sign in

Cards

  1. 1Abs()
    Returns the absolute value of a number (integer, float, or object implementing __abs__())
  2. 2All()
    True if all elements of the iterable are true (or if the iterable is empty)
  3. 3Any()
    True if any element of the iterable is true. If the iterable is empty, returns False
  4. 4Bin()
    Converts an integer number to a binary string prefixed with '0b'
  5. 5Bool()
    A Boolean value (True or False) using the standard truth testing procedure
  6. 6Breakpoint()
    Drops you into the debugger at the call site (calls sys.breakpointhook(), default: pdb.set_trace())
  7. 7Callable()
    True if the object appears callable, False if not
  8. 8Chr()
    Returns the string representing a character with the specified Unicode code point (inverse of ord())
  9. 9@classmethod
    A decorator that transforms a method into a class method that receives the class as implicit first argument
  10. 10Compile()
    Compiles source code into a code or AST object that can be executed by exec() or eval()
  11. 11Complex()
    A complex number from real and imaginary parts, or converts a string/number to complex
  12. 12Delattr()
    Deletes the named attribute from an object (delattr(x, 'foobar') is equivalent to del x.foobar)
  13. 13Dict()
    A new dictionary object
  14. 14Dir()
    Without arguments: names in current local scope. With an argument: list of valid attributes for that object
  15. 15Divmod()
    A pair of numbers consisting of quotient and remainder when using integer division (a // b, a % b)
  16. 16Enumerate()
    An enumerate object that yields tuples containing a count (from start, default 0) and values from iterating
  17. 17Default start value for enumerate()
    0 (can be changed with start parameter)
  18. 18Eval()
    Parses and evaluates a Python expression string and returns the result
  19. 19Exec()
    Executes dynamic Python code (string or code object), returns None
  20. 20Filter()
    An iterator from elements of iterable for which function is true (or all truthy elements if function is None)
  21. 21Float()
    Returns a floating-point number constructed from a number or string
  22. 22Format()
    Converts a value to a formatted representation as controlled by format_spec
  23. 23Frozenset()
    A new immutable frozenset object, optionally with elements from iterable
  24. 24Getattr()
    Returns the value of the named attribute of object (getattr(x, 'foobar') is equivalent to x.foobar)
  25. 25Globals()
    The dictionary implementing the current module namespace
  26. 26Hasattr()
    True if the string is the name of one of the object's attributes, False if not
  27. 27Hash()
    The hash value of the object (an integer used for dictionary key comparison)
  28. 28Help()
    Invokes the built-in help system (interactive use) - prints help page for a module, function, class, or object
  29. 29Hex()
    Converts an integer number to a lowercase hexadecimal string prefixed with '0x'
  30. 30Id()
    The identity of an object - an integer guaranteed to be unique and constant during its lifetime

And 47 more cards. Study the whole deck free

Articles about this deck

More Programming decks

See all
Study all 77 cards free