I Haz Codes

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Menu
Word statistics – Beginner

You are to create a program which will read in text from a file using the sample code below. The name of the text file will be “words.txt” and must be placed in the same place as your code.


myfile = open("words.txt", "r") # open file in read mode
fullTextFile = myfile.read() # read in the whole file
myfile.close() # close the file

# You now can use the variable fullTextFile as a string!

 

Once the text has been written in you must output the number of times each letter appears. It should be able to handle letters in a different case.

Some links to help you –
Iterating over a string -http://www.pythonlearn.com/html-008/cfbook007.html
Representing text in a computer (ASCII)- http://www.bbc.co.uk/education/guides/zpfdwmn/revision
ASCII -http://www.teach-ict.com/gcse_computing/ocr/214_representing_data/character/miniweb/pg2.htm

Ord/chr -http://www.dotnetperls.com/ord-chr


You need to log in or create an account to submit code!

Comments are closed.

Information