Basic I/O in Ruby

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.