def of price uses the name rate, which gets its first value only on a later line. Between two calls, the program changes rate.
def price(qty):
return qty * rate
rate = 3
a = price(2)
rate = 5
print(a, price(2))
What does the program print?Log in to join the discussion.
Loading…