0
0
Rubyprogramming~10 mins

String creation (single and double quotes) in Ruby - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a string with single quotes.

Ruby
greeting = [1]Hello[1]
Drag options to blanks, or click blank then click option'
A`
B"
C'
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using double quotes when single quotes are asked.
Using backticks which are for command execution.
2fill in blank
medium

Complete the code to create a string with double quotes.

Ruby
name = [1]Alice[1]
Drag options to blanks, or click blank then click option'
A"
B`
C'
D:
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes when double quotes are needed.
Using backticks which execute commands.
3fill in blank
hard

Fix the error in the string creation with quotes.

Ruby
sentence = [1]It's a sunny day[1]
Drag options to blanks, or click blank then click option'
A'
B:
C`
D"
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes causes syntax error with apostrophes inside.
Using backticks which are for command execution.
4fill in blank
hard

Fill both blanks to create a string with double quotes and interpolation.

Ruby
age = 25
message = [1]I am #{age} years old.[2]
Drag options to blanks, or click blank then click option'
A"
B'
C`
D:
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes disables interpolation.
Using different quotes at start and end causes syntax error.
5fill in blank
hard

Fill all three blanks to create a string with single quotes and escape the apostrophe.

Ruby
quote = [1]It\[2]s a beautiful day[3]
Drag options to blanks, or click blank then click option'
A'
B"
D\
Attempts:
3 left
💡 Hint
Common Mistakes
Not escaping the apostrophe causes syntax error.
Using double quotes but escaping apostrophe unnecessarily.