JkSoftware

Day 12 - more on scope and constants

Nov 19th, 2021 (edited)
43
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. enemies = 1
  4. print(enemies)
  5. def increase_enemies():
  6. return enemies + 1
  7. #print(f"enemies inside function: {enemies}")
  8.  
  9. enemies = increase_enemies()
  10. print(f"enemies outside function: {enemies}")
  11.  
  12. #local scope
  13. # def drink_potion():
  14. # potion_strength = 2
  15. # print(potion_strength)
  16.  
  17. #drink_potion()
  18.  
  19.  
  20. # #global scope
  21. # player_health = 10
  22.  
  23. # def drink_potion():
  24. # potion_strength = 2
  25. # print(potion_strength)
  26. # print(player_health)
  27.  
  28. # drink_potion()
  29. # print(player_health)
  30.  
  31.  
  32.  
  33. #globalconstants
  34. PI = 3.14
  35. URL = "google.com"
  36.  
RAW Paste Data Copied