Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using python 3, I ALWAYS RATE MY ANSWERS. tHANKS Copy princess.txt from my 153 public folder on smaug to your folder that contains myfunctions.py 1.Construct

using python 3, I ALWAYS RATE MY ANSWERS. tHANKS

Copy princess.txt from my 153 public folder on smaug to your folder that contains myfunctions.py

1.Construct a list of all punctuation characters (use the string module classification set)

2.Use a list method to remove the apostrophe character (') from the above list

3.Prompt the user to enter the name of a file to read

4.For each line in the file

5.Use string methods to make it all lower case and remove any leading or trailing white space

6.Call your replace_chars function with the modified line (from step 5) and the list from step 2

7.Display the modified line (from step 6) preceded by the line number. Use the string format method in this step.

Here is princess.txt

Grandson|Cough, cough, cough. Cough, cough, cough. {Grandson is on the bed, playing video game.} Mother|{Enters.} Hi, honey. Grandson|Hi, Mom. Mother|{Kisses son and feels his forehead.} You feeling any better? Grandson|A little bit. Mother|Guess what? Grandson|What? Mother|Your Grandfather's here. {Opens curtains.} Grandson|Mom, can't you tell him I'm sick? Mother|You're sick? That's why he's here. Grandson|He'll pinch my cheek. I hate that. Mother|Maybe he won't. Grandfather|{Entering with a flourish.} Heyyyy!! How's the sickie? Heh? {Pinches boy's cheek. Boy looks at mother accusingly.} Mother|I think I'll leave you two pals alone. {Exits.} Grandfather|I brought you a special present. Grandson|What is it? Grandfather|Open it up. Grandson|{Opens the package. Disappointed.} A book? Grandfather|That's right. When I was your age, television was called books. And this is a special book. It was the book my father used to read to me when I was sick, {takes book} and I used to read it to your father. And today I'm gonna read it to you. Grandson|Has it got any sports in it? Grandfather|Are you kidding? Fencing, fighting, torture, revenge, giants, monsters, chases, escapes, true love, miracles... Grandson|Doesn't sound too bad. I'll try to stay awake. {Turns off TV.} Grandfather|Oh, well, thank you very much, very nice of you. Your vote of confidence is overwhelming. All right. {Puts glasses on.} The Princess Bride, by S. Morgenstern. Chapter One. Buttercup was raised on a small farm in the country of Florin

HERE IS REPLACE_CHARS

def replace_chars(s,li): for c in li: s= s.replace(c," ") return s if __name__=="__main__": import test print('testing function') test.testEqual(replace_chars(" SampIEam*", ["p", "E", "*"])," Sam I am ") test.testEqual(replace_chars(" Test1", ["e", "1"])," T st ") test.testEqual(replace_chars(" Salt@12", ["S", "@"])," alt 12")

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic Net Database Programming

Authors: Rod Stephens

1st Edition

0789726815, 978-0789726810

More Books

Students also viewed these Databases questions

Question

Write a Python program to check an input number is prime or not.

Answered: 1 week ago