# 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:#

  1. 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.

  1. 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 variable phrase_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โ€.

  1. Replace the word โ€œcoolโ€ with โ€œawesomeโ€ using Python.

  • The replace(old, new) method in Python replaces all occurrences of old with new 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")