Input and Output

Output is anything a program produces: text on a screen, a saved file, a sound. Input is anything a program receives: a typed name, a button click, data from the internet.

In these lessons, print (Python) and console.log (JavaScript) are your output tools. They're how your program talks to you.

Producing output

PYTHON

print("Welcome home")

JAVASCRIPT

console.log("Welcome home"); 
Compare → Both lines do the same job: send text to the screen. Python calls its tool print. JavaScript calls its tool console.log and ends the statement with a semicolon. Same concept, different accent.
EXAMPLE
loading editor…
YOUR TURN
Your turn → Add a fourth line that prints the name of a place your family is from.
loading editor…

Syntax has to be exact. Every quote, bracket and parenthesis needs its partner, and in Python the spaces at the start of a line count. One slip and the program won't run; the message will say where.

Programs run top to bottom, one line at a time. First, then second, then third. The computer never skips ahead and never gets creative. Whatever order you write is the order it runs.

Mark this lesson complete

Signed in, your progress follows you to every device.

Next: Expressions and Statements →
← Back