Variables and Expressions

Expressions

  • Standard mathematical operators work like other languages:
     3 + 5
     3 + (5*4)
     3 ** 2
     'Hello' + 'World'

Variable assignment

     a = 4 << 3
     b = a * 4.5
     c = (a+b)/2.5
     a = "Hello World"
  • Variables are dynamically typed (No explicit typing, types may change during execution).

  • Variables are just names for an object. Not tied to a memory location like in C.
<<< O'Reilly OSCON 2000, Introduction to Python, Slide 10
July 17, 2000, beazley@cs.uchicago.edu
>>>