Basic I/O in Ruby

Watch out! This tutorial is over 2 years old. Please keep this in mind as some code snippets provided may no longer work or need modification to work on current systems.
Tutorial Difficulty Level    

The built-in gets function simply reads a line and returns it as a string. The chomp method from class String trims the line terminator. The prompts are generated with ordinary prints lacking a final newline.

Similarly, the to_f method of class String converts the input string to a floating-point number.