0

In this program:

num = 1
def fun1(num):
    print(num)

Does the variable num function as both a global and a local variable here? Because num is now a parameter, does that make it a variable local to fun1()?

BallpointBen
  • 9,406
  • 1
  • 32
  • 62
Tamamo
  • 73
  • 1
  • 1
  • 8
  • It's a global var – pissall Apr 16 '18 at 04:16
  • 1
    There are two variables with the name num in this script. The one in fun1 is local and doesn't last very long. The global one survives until the end of the script. To check this add the lines `fun1(2)` and `print(num)` to the end and see what happens. – Bill Apr 16 '18 at 04:22

0 Answers0