1. Download an ebook from https://www.gutenberg.org/ (this is free) in "Plain Text UTF-8" format. WITHOUT using the .replace() method, write a function named rename_character which takes two string...


1. Download an ebook from https://www.gutenberg.org/ (this is free) in "Plain Text UTF-8" format.
WITHOUT using the .replace() method, write a function named rename_character which takes two string arguments, corresponding to an existing character name and a new character name, and prints the book line by line to the screen replacing the old character name with the new.
For example, I could replace Alice with my own name in Alice's Adventures in Wonderland.
NOTE: Do not submit the ebook file, just the code. We will run the code on the ebook we download.


2. Expand the previous function to take 2 lists of strings as arguments, still NOT using the .replace() method. The names in the first list should be replaced by the corresponding names in the second list.
For example: ['Alice', 'the White Rabbit', 'the Queen of Hearts'], ['Phoebe', 'Chandler', 'Monica'] as arguments would replace all occurrences of 'Alice' with 'Phoebe', all occurrences of
'the White Rabbit' with 'Chandler' and all occurrences of 'the Queen of Hearts' with 'Monica'.


3. Create a mad libs function which picks a paragraph from the ebook, checks for nouns and/or adjectives from a list, and prompts the user to replace them.
For example:
"Just then her head struck against the roof of the hall: in fact she was
now more than nine feet high, and she at once took up the little golden
key and hurried off to the garden door."
Code identifies "head" as a noun and prompts the user to enter a noun, the user enters "cat".
Code identifies "hall" as a noun and prompts the user to enter a noun, the user enters "table".
Code identifies "little" as an adjective and prompts the user to enter an adjective, the user enters "snowy".
The code prints the new paragraph:
"Just then her cat struck against the roof of the table: in fact she was
now more than nine feet high, and she at once took up the snowy golden
key and hurried off to the garden door."

Apr 03, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here