# You must make sure to run all cells in sequence using shift + enter or you might encounter errors
from pykubegrader.initialize import initialize_assignment
responses = initialize_assignment("2_strings_q", "week_2", "readings", assignment_points = 15.0, assignment_tag = 'week2-readings')
# Initialize Otter
import otter
grader = otter.Notebook("2_strings_q.ipynb")
โPootie Tangโs Wild String Manipulation Adventures#
# Run this block of code by pressing Shift + Enter to display the question
from questions._2_strings_q import Question1
Question1().show()
# Run this block of code by pressing Shift + Enter to display the question
from questions._2_strings_q import Question2
Question2().show()
# Run this block of code by pressing Shift + Enter to display the question
from questions._2_strings_q import Question3
Question3().show()
Pootie Tangโs Legendary Quotes#
Instructions:#
Write a Python program that:
Stores the following phrases in a list:
"Wa Da Tah!", "Sa Da Tay!", "Sine your pitty"
. List are defined using square brackets[]
with each element separated by a comma.For example:["element1", "element2", "element3"]
.Joins the phrases into a single string, separated by a comma and a space. You should use the built in string method
join()
.Prints the resulting string.
phrases = ...
result = ...
print(result)
grader.check("Pootie-Tangs-Famous-Quotes")
Pootie Tangโs Famous Quotes#
Instructions:#
Pootie Tangโs iconic phrase โWa Da Tah!โ is already attention-grabbing, but letโs make it LOUDER by converting it to uppercase.
Write Python code to convert โWa Da Tah!โ into all uppercase letters.
upper()
is a string method that converts all lowercase letters in a string to uppercase.This ensures Pootieโs catchphrase gets the volume it deservesโperfect for a high-energy scene in the movie.
save the original string to the variable
phrase
and the uppercase version to the variablephrase_upper
.
def catchphrase():
phrase = ...
upper_phrase = ...
print(upper_phrase)
catchphrase()
grader.check("coding-uppercase-pootie-tang")
Pootie Tangโs is Awesome#
Instructions:#
PootieTang always knows how to tweak his phrases for maximum impact. Suppose the string โPootieTang is coolโ needs an upgrade to โPootieTang is awesomeโ.
Replace the word โcoolโ with โawesomeโ using Python.
The
replace(old, new)
method in Python replaces all occurrences ofold
withnew
in a string.This allows Pootie Tang to adapt his style on the fly, just as he does in the film when he updates his approach to saving the day.
def replace_name():
pt_phrase = "PootieTang is cool"
modfied_phrase = ...
print(modfied_phrase)
replace_name()
grader.check("coding-replace-pootie-tang")
Submitting Assignment#
Please run the following block of code using shift + enter
to submit your assignment, you should see your score.
from pykubegrader.submit.submit_assignment import submit_assignment
submit_assignment("week2-readings", "2_strings_q")