Name: ______________ Net id: _____________ || Name: ______________ Net id: _____________ Name: ______________ Net id: _____________ || Name: ______________ Net id: _____________
do_mad_lib
what is the purpose of this
code in the function (you can remove it to see what it does)?
re.sub
does not change its argument contents
,
i.e., that the function re.sub
returns a value but doesn't have a side-effect on its parameter?
get_word_from_user
for
each element in all_tags
?
subs =
For that line to work, the string template
must have
an occurrence of the string "%s" for every corresponding
replacement found in the list subs
. What line of code
that was provided in do_mad_lib
caused the string "%s" to
replace each tag, e.g., "<adjective>" in the string read
from the file template_name
? Why do you think it's this line?
read_tagstore
function loops over each line
that it reads, what is the purpose of calling line.strip()
?
key
. What code did you write to add values to an
already existing dictionary value (a list) corresponding to key?
all_tags
, but generates them automatically
by calling get_word_from_computer
?
do_mad_lib
have when you've
finished this section?
print_out
curr_len
if the line was
too long? Why did you do this?
curr_len
did you make when printing the word followed by a space?
print word,
sufficient to print a
word, followed by a space, and remain on the same line for
the next print?
What is the category of the tag-a-story, Mad Lib you created?