



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




The Online Python Tutor shows them to you The very curious can look at the Python module traceback; this is used by our cunittest module to print frame information.
new constants violate_physics: 3 42 const_list lt_speed pi id 3 × 10 8
h 6 × 10
id
8 lt_speed "lt_speed = new" wouldn't change the global lt_speed. image source (surely not original): http://4.bp.blogspot.com/_c4VqqkgR0xY/ TLHr8YE7RxI/AAAAAAAAAzg/hlPsnjG_Q4k/ s1600/GENIE-1.gif But I have the true name id3 stored in constants. "constants.lt_speed = new" does change the value in id3.
def f(x, y): """Returns: x times square of y""" (^1) return x * (y**2) lt_speed = 3e print g(3) code with function call function definitions m E g: 1 3 def g(m): """Returns: energy equivalent of mass m""" (^1) E = f(m, lt_speed) (^2) return E
8 lt_speed x y f: 1 3 3 × 10 8
Two "live" frames (stack shown growing downwards, here)
def f(x, y): """Returns: x times square of y""" (^1) return x * (speed**2) lt_speed = 3e print g(3) code with function call function definitions m E g: 1 3 def g(m): """Returns: energy equivalent of mass m""" (^1) E = f(m, lt_speed) (^2) return E x y f: 1 3 3 × 10 8
Traceback (most recent call last): ... line 2, in
8 lt_speed
Flower num_petals he_loves_me
True id The number of petals. ≥ 0, initialized to random number. None if there are no petals. Otherwise, True if the next petal corresponds to "he loves me", False if it corresponds to "he loves me not".