To start this lab, download this zip file.
Lab 13 - Strings
Activities
repeat_exclamation.py
Write a function repeat_exclamation(sentence, punctuation, repeat_number)
that adds the punctuation to the end of the sentence a designated repeat_number of times.
For example:
repeat_exclamation("I love provo", "!", 5)
Would return:
"I love provo!!!!!"
wrap_in_box.py
Write a function wrap_in_box(text) that wraps the given text in a box using the characters ”-” and ”|“.
For example:
wrap_in_box("hello")
Would return:
---------
| hello |
---------
Note: Make sure there is a space between each ”|” and text.
censor_digits.py
Write a function censor_digits(input_file, output_file) that writes an output_file that has the same contents as input_file but all of the digits are replaced with ”*“.
Example
Input
My favorite number is 7.
42 is the answer.
Yes.
Output
My favorite number is *.
** is the answer.
Yes.
cougars.py
Write a function cougars(input_file, output_file) that writes an output_file that has the same contents as input_file but only includes the lines that contain ‘Cougars’, ‘cougars’, or ‘COUGARS’.
Example
Input
BYU's mascot is a cougar.
His name is Cosmo.
Cougars are my favorite animal.
I like cougars
LETS GO COURGARS!
Output
Cougars are my favorite animal.
I like cougars
LETS GO COURGARS!
Grading
| Activity | Points |
|---|---|
repeat_exclamation.py | 7 |
wrap_in_box.py | 7 |
censor_digits.py | 8 |
cougars.py | 8 |