Today we spent the first half of the class doing an exercise with our laptop screens down and writing code snippets on paper.
The idea was to display our knowledge of Python data structures and therefore the methods they utilize. Why it was intended to do this without our laptops or the internet, I don’t know. It would have been much more effective to provide us with code problems that required us to use this knowledge in order to solve them.
Global variables are variables that can be accessed anywhere in the program allowing them to be used across multiple functions ( in any scope ). I now know that to access a global variable you need to use the keyword global before the variable name e.g.
global globalVariable = localScopeValue
I learnt about global variables earlier during some other research I was doing for Python programming, the interesting part is that Python’s global variables do not automatically get passed down into local scopes ( e.g. functions etc ).
I already new that global variables were a thing ( having already used two other programming languages ) so what I learnt from this was how to use them specifically in Python.
I will be filling any remaining gaps in my knowledge through experimentation and researching on the internet.
The work I’ve done as part of the class exercises ( as well as my own tinkering ) can be found in the following repository in the “Playground” folder: