def hello_name(name):
"""
Given a string name, e.g. "Bob", return a greeting of the form "Hello Bob!".
"""
return "Hello " + name + "!"
def make_abba(a, b):
"""
Given two strings, a and b, return the result of putting them together
in the order abba, e.g. "Hi" and "Bye" returns "HiByeByeHi".
"""
return a+2*b+a
def make_tags(tag, word):
"""
The web is built with HTML strings like "Yay" which draws Yay as
italic text. In this example, the "i" tag makes and which surround
the word "Yay". Given tag and word strings, create the HTML string with tags
around the word, e.g. "Yay".
"""
return ""+word+""
def make_out_word(out, word):
"""
Given an "out" string length 4, such as "", and a word, return a new
string where the word is in the middle of the out string, e.g. "".
"""
return out[:2] + word + out[2:]
def extra_end(str):
"""
Given a string, return a new string made of 3 copies of the last 2 chars
of the original string. The string length will be at least 2.
"""
return str[-2:]*3
def first_two(str):
"""
Given a string, return the string made of its first two chars, so the
String "Hello" yields "He". If the string is shorter than length 2, return
whatever there is, so "X" yields "X", and the empty string "" yields the
empty string "".
"""
return str if len(str)