Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

need answer for all of this one asap it's Python homework 1. Write a function unique Words that takes a list of sentences (strings). You

need answer for all of this one asap
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
it's Python homework
image text in transcribed
image text in transcribed
image text in transcribed
1. Write a function unique Words that takes a list of sentences (strings). You will return a list of unique words found across all the sentences. Case needs to be ignored. The following shows several sample runs of the function: + >>> uniqueWords (this is a test', 'not too hard a problem', 'could be on a test, 'i like the word test']) ['this', 'is', 'a', 'test', 'not', 'too', 'hard', 'problem', 'could', 'be', 'on '1', 'like', 'the', 'word'] >>> uniqueWords (0) 0 >>> uniqueWords (I'Can you see, See you can', 'You can see']) ['can', 'you', 'see'] 1 2. Write a function hasLetters() takes a list of strings and letters as parameter. Returns a True if any of the words in the list contain the letters. False if it doesn't. The following shows several sample runs of the function: >>> hasLetters (['final', 'best', 'word','find' ], 'in') True >>> hasLetters(['final', 'best', 'word', 'find' ], 'zzz') False >>> hasLetters ([], 'a') False >>> hasLetters (['Zoko', 'Anthony', 'test'], 'Zo') True 3. Write a function replacer() that takes a list of sentences, and two strings. The wo strings represent the word to find and the word to replace it with. You will return a list of new sentences. The following shows several sample runs of the function: >>> replacer('This is a tent. Will your solution work in this test?', I bet it will. '1.'test,'exam") I'This is a exam.', 'Will your solution work in this exam?', 'I bet it will. '1 >>> replacer('The cat in the hat. , 'Cats have nine lives. Why does the cat igore me?.').cat", "kitty') ['The kitty in the hat.', cats have nine lives. , 'Why does the kitty ignore me?) True >>> hasletters ('final', 'best', 'word', 'find' ], 'in') >>> hasLetters (l'final', 'best', 'word', 'find'], 'zzz') >>> hasLetters (I).'a') >>> hasLetters (t'Zoko', 'Anthony', 'test'], '20') False LOON 000 False 7 8 9 True 3. Write a function replacer) that takes a list of sentences, and two strings. The wo strings represent the word to find and the word to replace it with. You will retum a list of new sentences. The following shows several sample nutes of the function 1005 Wind CRL E the > puerta The kitty the File de fom View all 5e 100 4. Implement a function number Logger. The function will ask the user to enter a series of numbers separated by a comma. The function will check each number and append every number that is greater than or equal to the second parameter to the file. You want catch errors that occur when opening the file. The following shows what the results of several runs of the function on one file Windows >>> number Logger('1.txt',5) Please enter a list of numbers seperated by a comma: 1,2,3,4,5,6,7,8,9 >>> number Logger(2.txt,50) Please enter a list of numbers seperated by a comma: 20,50.100 5. Write a function counter that read data from a values in the file are equal to the second parum file and you can assume it's an integer. You ms with the file Q Search 5. Write a function counter that reads data from a file and return a count of how many values in the file are equal to the second parameter. Each value is on its own line in the file and you can assume it's an integer. You must catch errors that occur when working with the file. >>> counter ('numbers.txt',30) 2 >>> counter ('numbers.txt',99) 1 >>> counter ('numbers2.txt',77) 2 >>> counter ('numbers2.txt', 60) 2 >>> counter ('numbers2.txt',55) 0 Submitting the assignment in the Assignment Implement the functions below in the file hw4.py which can be found on the fourth assignment section. You should save the template file I provided and inen modify that file by adding the bodies for the functions. When you do, make sure to remove the placeholder pass statements that are currently there. You must also write doc strings for every function. A submission without doc strings will not car full credit. 1. Write a function unique Words that takes a list of sentences (strings). You will retum a list of unique words found across all the sentences. Case needs to be ignored. The following shows several sample runs of the function: >>> unique words (t this is a test, not too hard a problems, could be on a testi, 1 like the word test']) ['this is a test, not', 'too', hard', 'proble', 'could', 'be', 'on 'i', 'like', 'the word'] >>> unique Words (1) >>> unique words (t can you see, see you can", "You can see')) ['can' you', see 2. Write a function hasLetters) takes a list of strings and letters as parameter. Returns a True if any of the words in the list contain the letters. False if it doesn't. The following shows several sample runs of the function: >>> hasLetters(['final', 'best', 'word', 'find' ], 'in') True >>> hasLetters (['final', 'best', 'word', 'find' ], 'zzz') False >>> hasLetters ([], 'a') False >>> hasLetters (['Zoko', 'Anthony', 'test'],'Zo') True 1. Write a fiction replace that takes a list of sering The repeat the wed to find and the word replace with nenors. The following seal sample of 4. Implement a function number. The function will ask themes of umented by the time will check the app humbet that is greater than or equal to the second parameters the file astet errors that werw when pening the file. The following shows a theme of several runs of the functionnelle >>> whers) Please enter list of sumber segerated by : 1.2.3.4.5.6.7.8. >>> bert50) Pean enter intet mbare sperately com: 20,50,400 M Wind CRL 100 Windows CELI - 5. Write a function counter that reads data from a file and return a count of how many values in the file are equal to the second parameter. Each value is on its own line in the file and you can assume it's an integer. You must catch errors that occur when working with the file. >>> counter ('numbers.txt',30) 2 >>> counter ('numbers.txt',99) 1 >>> counter ('numbers2.txt',77) 2 >>> counter ('numbers2.txt', 60) 2 >>> counter ('numbers2.txt',55) 0

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_2

Step: 3

blur-text-image_3

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

Mastering Influxdb Database A Comprehensive Guide To Learn Influxdb Database

Authors: Cybellium Ltd ,Kris Hermans

1st Edition

B0CNGGWL7B, 979-8867766450

More Books

Students also viewed these Databases questions