Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python3please Question 1a: Format String (2 points) Write a python function format string which takes a string and returns a copy of the input string,

python3please image text in transcribed
image text in transcribed
image text in transcribed
Question 1a: Format String (2 points) Write a python function format string which takes a string and returns a copy of the input string, with all letters converted to lower case and all punctuations removed For example, it the input string is "Wait, wait, vait, my friend" , then the function should return "wait vait vait my friend" n the following cell, the string containing all punctuations has been created for you M In 178 def fornat strings) resultstr = "" - for ch in s if (ch not in punctutions) result str result str eh return result str.Lover # Your code here PAle "cipyt hon-input-78-4028ado1042d, 1ine 4 reault str" IndentationErrori unexpected indent In 1791s fornat stringt Wait, wait, vait, my triend )n waie vale vait ny triend Traceback (nost recent call last) Nanetrror Question 1b: Unique Words (2 points) Write a python function unique words which takes a string and returns a set which contains all of the words in the string. We ignore letter cases and punctuations (all letters should be converted to lower case and all punctuations are removed). For example, if the input string is "Wait, wait, wait, my friend" ,then the function should return ('waitmyfriend You should not copy the code that is already in format string into this function. Call the corresponding function instead. In (671s det unique words (s): ent dict() first-s.splito for vord in firsti if word in ent ent[word]1 ent[word] 1 else return ent your code here In (68] unique words( 'Wait, wait, vait, my friendl)waitlmy Out [ 68]: False triend out 16911 False In 170] unique vords (punctuations)--set() Question 1c: Word Count (2 points) Write a python function word_count which takes a string and returns a in the input string. As in Question 1a and 1b, we ignore letter cases and punctuations (all letters should be converted to lower case and al punctuations dictionary ropresenting the words and the number of occurrence of the words are removed) For example, if the inout string is "Wait, wait, vait, my triend!" , then the function should return ("vait'3, , Eriend 11). You should not copy the code that is already in format string or unique words into this function. Call the corresponding function instead. In t : det word count (s) # Your code here In ( 1i word count( Wait, wait, vait, my friend'triand', nywaie 3 in Iword count (punctuations

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

Students also viewed these Databases questions

Question

Methods of Delivery Guidelines for

Answered: 1 week ago