Confused about Scripts, Console, and Terminal

Definitely a newbie question, but I’ve spent so much time learning the “code” that I definitely missed this basic distinction.

  1. As I understand it, a script is where you write the code… but then what is the console/terminal used for? Are they just avenues through which the script is executed? I see people type into one of these, too (I think the terminal).

  2. Every tutorial I watch (specifically on Python or R) has the instructor execute a part of the code from the script. I assume the full code doesn’t need to be executed each time because the console “stores” the results. Is this right?

  3. If so, when I finish creating the script, do I need a console and/or terminal anymore or can I just run that script anywhere Python is understood?

3a. Basically, I know Google has a way to automatically run scripts. Is that where I would put the .py script file when I am done with it and would I need anything else to go with it?

As always, thanks in advance.

1 Like

A terminal is an interface for interacting with a computer. You input something (as “terminal” will normally refer to a text terminal, the something will be text), and that gets evaluated. Computers didn’t used to have GUIs, and you would interact with them by typing commands in. Nowadays you normally use a program called a terminal emulator to emulate that interface. GUIs are good for some things, text interfaces are good for other things.

A console is basically going to refer to the same thing, in that it is a command-line interface: you type commands in, and they get executed. For example, in a browser, you can open the browser console, which will allow you to execute arbitrary JavaScript code:

I think “console” as you understand it is referring specifically to a “REPL” (Read Evaluate Print Loop), which is a program for a specific language that lets you type in commands in that language. The one in the screenshot above is a JavaScript REPL that has access to the browser. So if you just type python in a terminal, you get the Python REPL:


The terminal or console is not really going to store anything beyond what the last command was, you’re literally just telling the computer/application to do something, and they do it.

For example, in a folder projects, I’ve run the command ls. ls is a utility program that, when invoked, lists all of the files/folders in the current directory, then exits, which is what this screenshot shows:

A script normally refers to a small program written in a scripting language (eg Python, Bash, Perl, PowerShell, Lua, JavaScript etc) that automates some task. You write the little program, then tell the interpreter for that scripting language to execute the script.

When you execute a Python script, what the computer will do is look for the Python executable, and use that to run whatever you tell it to run. ie if you have installed Python, it will come with a program that runs Python code which is normally invoked by typing python myScript.py (where myScript.py is some program you are trying to run). For example:

So in the folder database-ops, I am

  • running a Python script [which is in a file] called main.py which,
  • given some arguments (what I’m doing - create, what I’m creating - a proxy, the database I’m creating a proxy for - (redacted), and the port to use - 6000),
  • creates a database proxy.
  • The line after that shows the proxy has been created, and gives me some information (also redacted),
  • then tells me how to connect to it using another program on my computer (psql).
  • So I use psql with the arguments expected of it - it gives me a warning and asks for a password,
  • which I give it,
  • then it opens up the psql console, which is a console program that lets me type in arbitrary SQL commands.

Re Google automatically running scripts - you’re going to have to be a lot more specific as to what you’re trying to do, because yes, out of the millions of tools Google provides, some can be scripted with Python, but Google has an awful lot of tools.

2 Likes