Question: In python please! def frequency(text): Return value: A list (of integers): how often each letter of the alphabet appears in text Assumptions: o The standard

In python please! def frequency(text): 

Return value: A list (of integers): how often each letter of the alphabet appears in text

Assumptions:

o The standard English alphabet is used: "abcdefghijklmnopqrstuvwxyz"

o All strings will be entirely in lowercase, and only contain valid letters in the alphabet.

How it works:

o Count how many times each letter in the alphabet occurs in the text.

Store all of these values in a list.

o This list should be returned in alphabetical order: index 0 is the frequency of the letter "a" index 1 is the frequency of the letter "b" index 2 is the frequency of the letter "c" ... so on until the letter "z"

Notes: o Don't use list.index() or list.count()!

Examples: o frequency("abcd") [1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]

o frequency("zoosarecool") [1,0,1,0,1,0,0,0,0,0,0,1,0,0,4,0,0,1,1,0,0,0,0,0,0,1]

def common(frequencies):

Parameter(s): frequencies --- a list; the frequencies of letters in an unknown text (in alphabetical order) Return value: A tuple: the letter(s) that appeared most commonly in some piece of text Assumptions:

o The standard English alphabet is used: "abcdefghijklmnopqrstuvwxyz" How it works:

o This function should compute the letters in the alphabet that are "common" in a text. A "common" letter appears more than 10% of the time in a given text.

o If a letter is common, add it to the tuple of common letters. o When you have checked all of the letters in the alphabet, return the tuple of common letters.

The letters should be reported in alphabetical order.

Notes: o HINT: while the text itself is unknown, you can determine its length from the letter frequencies

Examples: o common([0,0,0,0,0,0,0,0,0,0,0,0,1,0,2,0,0,0,0,0,0,0,0,0,0,0]) ('m', 'o') o common([4,0,0,2,7,0,0,4,7,0,0,3,0,2,1,0,0,0,7,10,0,0,0,0,0,0]) ('e','i','s','t')

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!