I know that python has an automatic garbage collector and so it should automatically delete variables when there are no more reference to them.
My impression is tha
Implementations use reference counting to determine when a variable should be deleted.
After the variable goes out of scope (as in your example) if there are no remaining references to it, then the memory will be freed.
def a():
x = 5 # x is within scope while the function is being executed
print x
a()
# x is now out of scope, has no references and can now be deleted
Aside from dictionary keys and elements in lists, there's usually very little reason to manually delete variables in Python.
Though, as said in the answers to this question, using del can be useful to show intent.