SHARE
TWEET

Pruebas localidad

a guest May 19th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # variable inmutable
  2. def foo1(var):
  3.     var = 2
  4.     print(var)
  5. var1 = 1
  6. foo1(var1)
  7. print(var1)
  8. # output:
  9. # 2
  10. # 1
  11.  
  12. # variable mutable redefinicion
  13. def foo2(var):
  14.     var = [1, 2]
  15.     print(var)
  16. var2 = [1]
  17. foo2(var2)
  18. print(var2)
  19. # output:
  20. # [1, 2]
  21. # [1]
  22.  
  23. # variable mutable modificacion
  24. def foo3(var):
  25.     var.append(2)
  26.     print(var)
  27. var3 = [1]
  28. foo3(var3)
  29. print(var3)
  30. # output:
  31. # [1, 2]
  32. # [1, 2]
  33.  
  34. # variable global redefinicion
  35. def foo4():
  36.     global var4
  37.     var4 = 2
  38.     print(var4)
  39. var4 = 1
  40. foo4()
  41. print(var4)
  42. # output:
  43. # 2
  44. # 2
  45.  
  46. # variable global modificacion
  47. def foo5():
  48.     global var5
  49.     var5 += 1
  50.     print(var5)
  51. var5 = 1
  52. foo5()
  53. print(var5)
  54. # output:
  55. # 2
  56. # 2
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top