Exercise path · Ruby
10 Ruby exercises, in order
From your first line to a complete program you assembled yourself. Each exercise introduces exactly one new idea, runs in this tab, and tells you in plain language what happened.
How the path works
You never start from a blank editor. Every exercise hands you a program that already runs and asks you to change or add one thing, so the first success is minutes away and the last exercise is a program you can read top to bottom and explain. The ideas arrive in this order: output, variables, arithmetic, conditions, loops, loops and conditions, strings and formatting, arrays, putting it together, a complete program.
Run is the check. There is no separate submit button: press Run, and the output is compared with what the exercise asked for. When it is not right, the feedback is a sentence about what happened — the line that differed, or what the error means — rather than a verdict. Hints come one at a time, and the answer opens only after you have run your code at least once, because reading the answer first is how you learn nothing.
Your finished exercises and the code you last had in the editor are saved in this browser, so a half-done exercise is still there tomorrow. Nothing is uploaded and there is no account.
The exercises
- Hello, Out LoudA banner with your own name inside it, printed by code you ran yourself.New idea: puts prints text followed by one newline
- Name TagA conference name tag that prints a person's name and role from two variables, instead of typed-in text.New idea: A variable stores a value, and #{...} drops it into a string
- Party PlannerA pizza order summary that works itself out from a guest list — slices needed, whole pizzas, and the slices left over.New idea: Integer division truncates with /, and % gives the remainder
- Umbrella or NotA weather forecast that prints one of three different messages, decided automatically from a single number.New idea: if / elsif / else chooses between several outcomes
- CountdownA rocket countdown that prints every number from 5 down to 1, then announces liftoff.New idea: downto repeats a block once for every number in a falling range
- The Clapping GameA counting game from 1 to 10 that claps instead of saying any multiple of three out loud.New idea: an if inside a loop is decided again on every pass
- The ScoreboardA game scoreboard where every name, score and bar lands in the same column, no matter how long the name or how many digits the score has.New idea: ljust and rjust pad a string to a fixed width so columns line up
- Packing ListA travel packing checklist with a tick-box line for every item on the list, and a footer that counts them for you.New idea: An array holds several values in order, and each walks through them
- Rainfall WeekA seven-day rainfall report with a line for every day, the week added up underneath it, and the single wettest day picked out.New idea: a variable created before a loop carries a running total from pass to pass
- The Bike Rental ReceiptA printed bike-rental receipt with a header, three rental rows in straight columns, a subtotal, a weekend surcharge the program works out itself, a total, and a couple of closing notes.New idea: Assembling a complete program out of parts you already know
After the path
The Ruby playground is where to build something of your own, and the Ruby guide sets out a learning order for everything after the basics. Everything you can practise Ruby with on this site is gathered on the Ruby practice hub. The same path also exists in Python, JavaScript, TypeScript, Java, C++, C, C#, Go, PHP, SQL, R and Bash & the Shell.