ruby · level 1 · unit 1 · lesson 2
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
shows a message on the screen.
puts is a command that shows a message on the screen. Write puts, a space, then the message you want to see.
Words go inside quote marks, like "Hello, world!". A piece of text in quotes is called a . Picture the letters threaded on a string, like beads. puts is short for put string.
The quotes tell Ruby where your text starts and stops. They are not shown on the screen.
puts "Hello, world!" Use the same quote mark at both ends of your string.
guess first
What will appear on the screen?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
puts "My hamster is called Nibbles"
your turn
Your turn. Tell the computer about your favourite animal.
Type your favourite animal in place of the blank, keeping it inside the quotes. Then press run.
fix it
This line will not run. Can you fix it?
- Look closely at the two ends of the string. Do the quote marks match?
- The string starts with a double quote mark " but ends with a single one '.
- Change the ' at the end to ", then press run.
nailed it
you made the computer talk. :D
putsshows the string that comes after it.- Text inside quote marks is called a string.
- The quotes are not shown on the screen.
new words in your collection
- puts
- string
This lesson isn’t saved. A free account remembers every lesson you finish.