Look up global and local variables.
If you define them outside of any functions, such as right after including libraries, the variables are global. You can access them anywhere within the program.
If you define variables in a code block, when you need them, they are local. They only exist and are only accessible within that block. They disappear when you exit the block and are re-created the next time you enter the block.