Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python 3.6 Question 12 (2 points) write a function named uniqueWords that counts how many different words there are in each line of an input

Python 3.6

image text in transcribed

Question 12 (2 points) write a function named uniqueWords that counts how many different words there are in each line of an input file and writes that count to a corresponding line of an output file. The input file already exists when uniqueWords is called. uniquewords creates the output file. Input. The function uniquewords takes two parameters: inFile, a string that is the name of text file that is to be read. The file that inFile refers to contains only lower case letters and white space (no punctuation marks or other special characters) outFile, a string that is the name of the file to which uniqueWords writes its out put. The input file is in the current working directory. uniquewords should create the output file in that directory. output. For each line of infile, uniquewords should write a corresponding 1line to outFile containing a single integer: the number of unique words on the line If the content of the file turn.txt is below, a time to build up a time to break dowrn a time to dance a time to mourn a time to cast away stones a time to gather stones together the function call uniquewords ('turn.txt', 'turnout.txt') should create a file named turnout.txt with this content 7 5 8

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

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

3rd Edition

978-1119907466

More Books

Students also viewed these Databases questions