Question: Problem 0 a . Alphabet Dictionary Given the following string, write a program that counts how many times each letter or number has been used
Problem a Alphabet Dictionary
Given the following string, write a program that counts how many times each letter or number has
been used in the string. Use a dictionary to store your results.
Enter a phrase: "The lazy dog jumped over the curious cat"
Here's a sample running of your program:
Report in ascending order by ASCII value:
Enter a phrase: "The lazy dog jumped over the curious cat"
T
a
c
d
e
g
h
i
j
l
m
o
p
r
s
t
u
v
y
z Note this example only includes letters. Numbers would be placed, from before the letters and
after the spaces.
Problem b
In the example above, the ts are counted as separate letters. We want to count lowercase and
uppercase letters as the same and remove all characters that are not alphanumeric.
Begin by writing this convenience function this function will be useful to make sure that all of the
string data you will be working with is formatted correctly.
# function: cleanupstring
# input: a string to clean up
# processing: makes the entire string lowercase.
# retains only alphabetic and numeric characters
# all punctuation, spaces, and special characters removed
# output: returns the cleaned up string
def cleanupstringdata:
# TEST CODE
test cleanupstringHello World! This is a simple test of this function!"
print test
# helloworldthisisasimpletestofthisfunction
test cleanupstringABCabc this is Another TEST!!!#@@
print test
# abcabcthisisanothertest
In part a the string would be converted to
thelazydogjumpedoverthecuriouscat
and the output would be
Report in ascending order by ASCII value:
a c
d
e
g
h
i
j
l
m
o
p
r
s
t
u
v
y
z
Problem Points :
Dictionary is used to track how many of each letter; letters are keys, counts are values
points
Output of number and letter counts is sorted in ascending order points
Two test cases that ensure that any nonalphanumeric characters are removed and
letters and numbers are correctly counted points each; points each for the cleaned
string, points each for the sorted counts
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
