Assignment Task:
Task:
Python task week 2 Instructions
The "text.txt" contains a piece of text (it's the opening passage of Charles Darwin's On the Origin of Species).
Write a program that reads the text in the file and lists each unique word, along with its frequency (i.e., how many times it occurs).
Example: (These numbers might not be correct - they're just a guide to the sort of output you should generate.)
- when: 3
- we: 3
- look: 1
- to: 9
- the: 11
- ... etc.
- Your program should work not only for this file but also for variations. You may assume the following about the text in a file:
- First. Words are separated by whitespace. In the sample text given all of the whitespace is just a single space. But sometimes it might be multiple spaces, or tabs, or line breaks, etc. Make sure your program can handle all of these different kinds of whitespace. You will find the string method split very helpful.
- Second. The text might contain punctuation marks (as the sample text does). Make sure that you don't include punctuation marks in words. You could remove them from the text altogether, using the programming task from Week 1 as a guide. It will be good enough if your program can handle the following punctuation marks:
- . ? ! , ; : ( ) [ ] { } "
- Don't worry about dashes and single quote marks:
- - '
- These are tricky, because sometimes they are used as parts of words (e.g. hyphenated words, such as "sub-variety", or contractions, such as "aren't") and sometimes they are used not as part of words (e.g., as dashes or quote marks). If you feel like a challenge then you could get your program to deal with them correctly, but you're not expected to, and you won't lose marks if you don't.
- Third. Words might occur both with a capital first letter and without a capital first letter (e.g., the sample text contains both "When" and "when"). You should consider these to be the same word. You could make all words lower case, turning "When" into "when". Or you could make them all upper case, turning both "When" and "when" into "WHEN". It's up to you.
- Also, get the words to appear in alphabetical order. Even better, get them to appear in order of frequency, from the most frequent down to the least frequent. Again, you're not expected to, and you won't lose marks if you don't do either of these things.
The above Management Assignment has been solved by our Management Assignment Experts at onlineassignmentbank. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our experts are well trained to follow all marking rubrics & referencing style.
Be it a used or new solution, the quality of the work submitted by our assignment experts remains unhampered. You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed that you could choose one between the two and acquire an HD either way. You could choose a new assignment solution file to get yourself an exclusive, plagiarism (with free Turnitin file), expert quality assignment or order an old solution file that was considered worthy of the highest distinction.