Menu
support@nursinghomework.org
+1 714-215-3097

(Solved) : Write Function Called Lettercount Filename Accepts Single Parameter Containing Name File F Q35629132

Write a function called lettercount(filename) that accepts a single parameter containing the name of a file. Your function sh1 def letter_count(filename): count- e file_in open (filename, r) contents file_in.read() file_in.close() contents : conten

Write a function called lettercount(filename) that accepts a single parameter containing the name of a file. Your function should read the contents of the text file, and calculate the number of times each English letter appears in the file. The function should print a list of (Character: count) pairs to the standard output You may define additional “helper” functions as you wish. Any character that is not an English letter should be ignored. The case should be ignored (so both ‘a and ‘A’ count as the letter a Report he output with ower case letters. The letters should be sorted in to standard al habe a order and s ould be printed he om etr, he a space, then a colon, then a space, then the frequency. If a letter is not present in the file, then it should not be printed. Е.g. a 6 b:3 d :2 A student who completes this exercise should be able to: Read the contents of a text file . Use a dictionary to store keys and values Sort dictionary keys For example Test Input Result letter_count(‘test1.txt Contents of ‘testl.txt A simple file with only one ie :4 i: 4 1:4 n:3 1 def letter_count(filename): count- e file_in open (filename, “r”) contents file_in.read() file_in.close() contents : contents.lower() δ| Show transcribed image text Write a function called lettercount(filename) that accepts a single parameter containing the name of a file. Your function should read the contents of the text file, and calculate the number of times each English letter appears in the file. The function should print a list of (Character: count) pairs to the standard output You may define additional “helper” functions as you wish. Any character that is not an English letter should be ignored. The case should be ignored (so both ‘a and ‘A’ count as the letter a Report he output with ower case letters. The letters should be sorted in to standard al habe a order and s ould be printed he om etr, he a space, then a colon, then a space, then the frequency. If a letter is not present in the file, then it should not be printed. Е.g. a 6 b:3 d :2 A student who completes this exercise should be able to: Read the contents of a text file . Use a dictionary to store keys and values Sort dictionary keys For example Test Input Result letter_count(‘test1.txt Contents of ‘testl.txt A simple file with only one ie :4 i: 4 1:4 n:3
1 def letter_count(filename): count- e file_in open (filename, “r”) contents file_in.read() file_in.close() contents : contents.lower() δ|

Leave a Reply

Your email address will not be published. Required fields are marked *