0
0
Rubyprogramming~10 mins

Puts, print, and p output differences 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 print a string with a newline using puts.

Ruby
puts [1]
Drag options to blanks, or click blank then click option'
Ap
Bprint
C"Hello, world!"
Decho
Attempts:
3 left
💡 Hint
Common Mistakes
Using print instead of puts
Forgetting quotes around the string
2fill in blank
medium

Complete the code to print a string without a newline using print.

Ruby
print [1]
Drag options to blanks, or click blank then click option'
Aputs "Hello"
Bp "Hello"
Cecho "Hello"
D"Hello"
Attempts:
3 left
💡 Hint
Common Mistakes
Using puts which adds a newline
Using p which shows quotes
3fill in blank
hard

Fix the error in the code to show the string with quotes and newline using p.

Ruby
[1] "Hello, world!"
Drag options to blanks, or click blank then click option'
Ap
Bprint
Cecho
Dputs
Attempts:
3 left
💡 Hint
Common Mistakes
Using puts or print which do not show quotes
Using undefined method echo
4fill in blank
hard

Fill both blanks to print a string with and without newline.

Ruby
print [1]
puts [2]
Drag options to blanks, or click blank then click option'
A"Hello"
Bp "Hello"
C"World"
Dprint "World"
Attempts:
3 left
💡 Hint
Common Mistakes
Using p in print line
Using print in puts line
5fill in blank
hard

Fill all three blanks to print a string with quotes, without newline, and with newline.

Ruby
[1] "Test"
print [2]
puts [3]
Drag options to blanks, or click blank then click option'
Ap
B"Test"
C"Done"
Dputs
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up print and puts
Not using quotes for strings