Skip to content
AgileLogics
Beginner 5 min read

Beginner Projects

Prerequisites: Level 1 — Beginner

Build these with nothing but what Level 1 covered — puts, gets, strings, numbers, conditionals, loops, arrays, hashes, methods, and blocks. Each one fits in a single .rb file.

1. Command-Line Calculator

Ask for two numbers and an operator (+ - * /) with gets.chomp, convert the numbers with Float(...), and print the result using a case statement. Print a friendly message for division by zero or an unknown operator instead of crashing.

Hint: wrap the conversion in begin/rescue ArgumentError to catch input like abc.

2. Number Guessing Game

Pick a secret number with rand(1..100), then loop, reading guesses and printing "Too high" or "Too low" until the player gets it right. Count and print the number of attempts at the end.

3. To-Do List

Keep tasks in an array of hashes like { title: "Buy milk", done: false }. Loop over a menu (add / list / done / quit) handled with case, and use each_with_index to print numbered tasks with a [x] or [ ] marker.

4. Unit Converter

Store conversion factors in a hash ({ "km_to_miles" => 0.621371, ... }), list the options, and convert the number the user enters. Round results with round(2).

5. Password Generator

Ask for a length, then build a password by sampling from an array of letters, digits, and symbols ([*"a".."z", *"A".."Z", *"0".."9"]). Use Array.new(length) { chars.sample }.join. Then try replacing sample with SecureRandom.alphanumeric (after require "securerandom") — the better choice for real passwords.

6. Simple Quiz

Store questions and answers in an array of hashes, ask each one, compare answers case-insensitively with casecmp?, and print a final score like You scored 4/5.

7. Word Frequency Counter

Read a sentence, split it into words with downcase.scan(/\w+/), count them with tally, and print the five most common words with sort_by { |_, count| -count }.first(5).