Saturday, January 2, 2016

Day 6

https://docs.python.org/2/library/

Functions use arguments

Print(variable) for example
In this example



  1. def spam():
  2.     eggs = 99
  3.     return eggs

  4. number = spam()
  5. print (number)


Line 6 needs the argument (number)  or it will never print 99, you will get an error.


Global and local scope. 

pythontutor.com/visualize.html


Change a global variable with a local scope variable 

  1. def spam():
  2.        global eggs
  3.        eggs = 'Hello'
  4.        print = (eggs)


  5. eggs = 42
  6. spam()
  7. print(eggs)

Try and Except



Left off on lecture 12

No comments:

Post a Comment