Working With The Console

The Console is an one of the essential tools that you will find useful in many situations. The Console has too main functions. First, it will display error, messages and program output (i.e. stderr and stdout). Second, you can use it as an input device to your programs (i.e. stdin).

Outputting To The Console

You don't need to do anything special to output to the console. The console is directly integrated with all development environments. Here are some examples.

Python

print 'Hello World!'

Ruby

puts 'Hello World!'

JavaScript

console.log('Hello World!');

All of these snippets of code will output to the console. Keep in mind that you can also use ANSI escape codes to output in color and even draw shapes and more. For more information, look for "curses" or "ncurses" support in your favorite programming language.

Taking Input From The Console

Your programs may require input from the user using the standard input (i.e stdin). This feature is directly integrated into the console. Here are some examples.

Python

print raw_input('What is your name: ')

Ruby

print "What is your name: "  
STDOUT.flush
puts gets.chomp

JavaScript

// no standard way of getting input unless you use node.js

In order to supply input, simply click inside the console and start typing. Keep in mind that you will not be able to type unless your program is waiting for input just like in the examples above.