Skip to content

Instantly share code, notes, and snippets.

@catb0t
Created January 12, 2023 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save catb0t/07c767d0fc100f7599ade4e678542dba to your computer and use it in GitHub Desktop.
Save catb0t/07c767d0fc100f7599ade4e678542dba to your computer and use it in GitHub Desktop.
python questions
  1. A Python list is a mutable ordered collection of values. A Python tuple is an immutable ordered collection of values. A list could be [1, "a", object(), 5]. A tuple could be (1, "a", object(), 5).

  2. A namespace in Python is a syntactic construction, which has a unique identity, a name, and a set of values which are declared and logically stored inside it. Often (and when not private), they can be accessed from outside of the namespace using dot syntax. Modules, files, class declarations, and function definitions all create namespaces.

  3. A global variable is accessible at the file scope, and therefore in all enclosed scopes that inherit outer scopes' globals. If it is not private, a module-global variable is also accessible and mutable by other modules. The scope of a local variable is limited to the class declaration, function definition, with statement, or scoping control block such as if or for in which it was first declared.

  4. An IDE or Integrated Development Environment is a design, engineering and debugging tool allowing a programmer to write syntax highlighted code with help from completion and introspection tools, check the program statically for errors before it is run, debug the program while it is running, and manage project and program structure.

  5. A Python module is a logical structure which associates together and organises related and interdependent code, so that it can be run, compiled, shipped, or imported as a package all at once. A module may be a single file, which can be imported directly, or it may be a folder structure with __init__.py, __main__.py and so on. A class declaration can also create a module under the right circumstances. Examples of Python modules are a_file (when a_file.py exists in the current directory), time, and abc.

  6. Python does not expose CPython arrays as a user language feature. An array is a strictly-typed homologous ordered collection of the same hardware data type. Python array implementations provided by libraries such as numpy abstract over Python's list syntax, and provide their own highly-optimised functions for working with sets of data that are known to be of a single type, such as int. A Python list is an abstraction and a language feature which represents a mutable ordered collection of Python values. As a result of their dynamic typing, Python lists do not represent hardware types directly, and instead contain pointers to CPython objects.

  7. A Python operator is a syntactic structure consisting of one or more characters, which has a logical meaning about how to handle those values. Values that appear adjacent in Python syntax must always be separated by an operator. Examples of operators are , (the comma operator for separating values), + (the __add__ operator), and is (the identity comparison boolean operator).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment