Ruby String Exercises: Draw a string as bold or italic text
Ruby String: Exercise-1 with Solution
Write a Ruby program to draw a string as bold or italic text.
Ruby Code:
def make_tags(tag, word)
"<#{tag}> #{word} </#{tag}>"
end
print make_tags("i", "Ruby")
print "\n",make_tags("b", "Ruby")
Output:
<i> Ruby </i> <b> Ruby </b>
Flowchart:
Ruby Code Editor:
Contribute your code and comments through Disqus.
Previous: Ruby Array Exercises
Next: Write a Ruby program to insert a string of length 2 to an another string where the first string will be in the middle of the second string.
What is the difficulty level of this exercise?
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework