How many words there are in each line of an input file

Assignment Help Financial Management
Reference no: EM132360724

Question 1:

Write a function named wordCount that counts how many 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 wordCount is called. wordCount creates the output file.

Input. The function wordCount takes two parameters:

i. inFile, a string that is the name of a text file that is to be read and analyzed. The file that inFile refers to contains only upper and lower case letters and white space (no punctuation marks or other special characters).

ii. outFile, a string that is the name of the file to which wordCount writes its output. //The Result
The input file is in the current working directory and you should create the output file to that directory.

Output. For each line of inFile, wordCount should write a corresponding line to outFile containing a single integer: the number of words on the line.

If the content of the file catInTheHat.txt is below,

The sun did not shine
It was too wet to play
So we sat in the house
All that cold cold wet day
I sat there with Sally
We sat there we two
And I said How I wish
We had something to do

the function call
wordCount('catInTheHat.txt', 'catInTheHatOut.txt') should create a file named catInTheHatOut.txt with this content:

5
6
6
6
5
5
6
5

Question 2:

Write a function named initialVowels that analyzes the contents of a text file for words that begin with a vowel. The letters a, e, i, o and u are vowels.

The function initialVowels should return a dictionary of vowel:word-list pairs. Each vowel should be a key in the dictionary if and only if it is the first letter of some word in the input file. The value of a key is a list of all the words in the input file in which that vowel is the first letter. (Hint: your job is easier if you lowercase the text in the input file.)

Input. The function initialVowels takes a single parameter:
i. inFile, a string that is the name of a text file. This file contains only upper and lower case letters and white space (no punctuation marks or other special characters). It is in the current working directory.

Output. Return a vowel:word-list dictionary

For example, if the file named catInTheHat.txt contains the same text as in Question 12, then the function call
print(initialVowels('catInTheHat.txt'))
should output

{'i': ['it', 'in', 'i', 'i', 'i'], 'a': ['all', 'and']}

Reference no: EM132360724

Questions Cloud

Explain challenges and risks involved in m-commerce : Submit a 2 to 3 page paper focused on challenges and risks involved in m-commerce. Provide an example of an organization that has successfully implemented.
Have these problems affected their execution of strategy : Strategies involving mergers and acquisitions are particularly vulnerable to cultural problems. Have these problems affected their execution of strategy?
What is the difference between tuples and lists in python : What is the difference between tuples and lists in Python? The response paper should be in APA format, double spaced,hand-written.
Describe the purpose of the quality improvement initiative : In this assignment, you will propose a quality improvement initiative from your place of employment that could easily be implemented if approved.
How many words there are in each line of an input file : Write a function named wordCount that counts how many words there are in each line of an input file and writes that count.
Describe benefits of attending a meeting and convention : Write a 700-word proposal to your employer outlining the benefits of joining the selected health care association and the benefits of attending a meeting.
Health promotion as new priority for the upcoming year : You have recently been assigned Health Promotion as a new priority for the upcoming year. Review the C-Span Health Promotion
Explain the staging of end-stage renal disease : Explain the staging of end-stage renal disease (ESRD) and contributing factors to consider. Consider ESRD prevention and health promotion opportunities.
Role of an it project manager to produce a project plan : BCO6656 - IT PROJECT MANAGEMENT - Develop a schedule for the project comprising at least 50 tasks using Microsoft Project tool

Reviews

Write a Review

Financial Management Questions & Answers

  Foreign company acquisition

Acquisition by a foreign company and the effects of that decision and the results of foreign exchange in Euro and the exchange rate differences.

  Financial management for profit and non profit organizations

In this essay, we are going to discuss the issues of financial management in a non-profit organisation.

  Method for estimating a venture''s value

Evaluate venture's present value, cash and surplus cash and basic venture capital.

  Replacement analysis

This document show the Replacement Analysis of modling machine. Is replacement give profit to company or not?

  Business finance task - capital budgeting

Your company is considering using the payback period for capital-budgeting. Discuss the advantages and disadvantages of this technique.

  Analysis of the investment

In this project, you will focus on one of these: the additional cost resulting from the purchase of an apple press (a piece of equipment required to manufacture apple juice).

  Conduct a what-if analysis

Review the readings and media for this unit, including the Anthony's Orchard case study media. Familiarise yourself with the Anthony's Orchard company and its current situation.

  Determine operational expenditures

Organisations' behaviour is guided by financial data. In the short term, such data will help determine operational expenditures; in the long term, historical data may help generate forecasts aimed at determining strategic plans. In both instances.

  Personal financial management

How much will you have left over each half year if you adopt the latter course of action?

  Sources of finance for expansion into new foreign markets

A quoted company is considering several long-term sources of finance for expansion into new foreign markets.

  Long term financial planning

This assignment is designed for analyze Long term financial planning begins with the sales forecast and the key input in the long term fincial planning.

  Explain the role of fincial manager

This assignment explain the role of fincial manager, function of manger. And what are the motives of financial manager.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd