Variables, Data Types, and Simple Pipelines

Computer Architecture and Memory Abstraction

  • Programs stored on a hard drive are loaded into Random Access Memory (RAM) when executed.

  • The Central Processing Unit (CPU) fetches instructions and reads or writes data in RAM.

  • Variables function as labeled storage locations within computer memory.

Variable Assignment and Memory Functions

  • Assignment statements use the equals operator (=) in the form <variable> = <expression> to evaluate an expression, store the result in memory, and bind the variable label to that location.

  • id(): Returns the memory location address of a specified variable.

  • hex(): Converts a numerical argument into its hexadecimal representation.

Data Types and Character Encoding

  • Memory represents different data types (numeric, textual, and logical) using binary sequences.

  • Strings are sequences of characters enclosed in quotation marks (e.g., "xyz" represents a literal string, whereas xyz references a variable).

  • The American Standard Code for Information Interchange (ASCII) provides a mapping that assigns integer values to specific textual characters.


Data Type Hierarchy Diagram
  • Primary Data Types:

    • Numeric: Integer (numbers without a fractional component) and Floating Point (approximations of real numbers).

    • Boolean: Truth values represented as True or False.

    • Sequential: String (sequences of ASCII characters).

Input, Output, and Type Conversion

  • input(): Reads user input typed into the terminal and returns it strictly as a String data type.

  • Text strings representing numbers (e.g., "123") are stored as ASCII character sequences and are distinct from numeric values (e.g., 123).

  • Type Conversion Functions:

    • int(): Converts an argument into an Integer.

    • float(): Converts an argument into a Floating Point number.

    • chr(): Converts an integer ASCII value into its corresponding character.

    • type(): Returns the data type classification of an argument.

Pipeline Design Pattern and Mathematical Operators

  • The Pipeline design pattern organizes programs into process chains where the output of one process serves as the input for the next (Input-Process-Output).

  • Python provides explicit symbols for arithmetic operations:


Python Arithmetic Operators