Since your file (module) is called random.py, import random will import this very file.
Now, what does "import" mean?
The statement import something will cause Python to lookup the name something, starting with the current directory.
Therefore, import random will result in an import of this very file, since its name will shadow the build-in random.
Besides, if the name to import is already in the namespace, then the import statement is ignored.
Once the module to import has been located, its code is executed.
As a result, the flow of your script is as follow:
- Lookup the random.pyname
- Add randomto the namespace
- Execute the code contained in random.py
- The randomname already exists in the namespace, so theimport randomstatement is ignored
- Print the text
 
- Print the text