0
0
Rubyprogramming~5 mins

String methods (upcase, downcase, strip) in Ruby - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the upcase method do to a string in Ruby?
The upcase method converts all the letters in a string to uppercase letters.
Click to reveal answer
beginner
How does the downcase method affect a string?
The downcase method changes all letters in the string to lowercase letters.
Click to reveal answer
beginner
What is the purpose of the strip method in Ruby strings?
The strip method removes any spaces or whitespace characters from the start and end of the string.
Click to reveal answer
intermediate
Given the string " Hello World ", what will strip.upcase return?
It will return "HELLO WORLD". First, strip removes spaces at the start and end, then upcase changes all letters to uppercase.
Click to reveal answer
beginner
True or False: downcase changes numbers and symbols in a string.
False. downcase only changes uppercase letters to lowercase. Numbers and symbols stay the same.
Click to reveal answer
What does "Ruby".upcase return?
A"ruby"
B"Ruby"
C"RUBY"
D"rUBY"
What will " space ".strip return?
A"space"
B" space "
C"space "
D" space"
Which method changes all letters in a string to lowercase?
Acapitalize
Bstrip
Cupcase
Ddowncase
What does " Hello ".strip.upcase return?
A" HELLO "
B"HELLO"
C"hello"
D"Hello"
Does strip remove spaces inside the string?
ANo, only spaces at the start and end are removed
BYes, all spaces are removed
CYes, but only tabs
DNo, it does nothing
Explain how you can use upcase, downcase, and strip methods to clean and format a user input string.
Think about removing extra spaces and making all letters the same case.
You got /4 concepts.
    What happens if you call strip on a string with no spaces at the start or end?
    Consider if the string is already clean.
    You got /3 concepts.