Working with Variables in Print

Variable Types

Print handles all Python data types:

  • Numbers (int, float)
  • Strings
  • Lists and Tuples
  • Dictionaries
  • Custom Objects

Type Conversion

Print automatically calls __str__ or __repr__ on objects:

  • Implicit conversion
  • Custom string representations
  • Formatting options

Variable Interpolation

Different ways to include variables in output:

  • String concatenation
  • Format method
  • F-strings (recommended)
  • Template strings

Scope Considerations

Understanding variable scope when printing:

  • Local variables
  • Global variables
  • Function parameters
  • Class attributes