Question: 1 . Create a Python program file called Ch 0 9 - 2 _ Name.py . ( Replace Name with your initial of first name
Create a Python program file called ChName.pyReplace Name with your initial of first name and first letters of last name. If your last name is shorter than letters, just use full last name, it doesn't have to be letters. ie if your name is John Doe, your file name should be ChJDoe.py
Your program will take a file name from user and find out occurrences of words in the file. Case shouldn't matter, ie "the" and "The" should be counted as same word. Your output should list each word and occurrences of it in the file. Also, at the end, your program needs to print out number of different words in the file. You need to use Python Dictionary for this assignment. Make sure to exclude special characters. But words like "don't", "we'll" should be counted the way they are. Upper case and lower case letters should be treated the same, ie "But" and "but" should be counted as same word
Then output list of words and their occurrences in alphabetical order. One word per line with occurrences.
If user enters wrong information wrong name of the file or nonexisting file name your program needs to display message and ask for correct input. Your program should not generate traceback message with any input.
Your program's output should be exactly same or very close to the sample output provided. Output should be formatted to match the sample output provided or points will be deducted up to points
OUTPUT:
Please enter file name: abc.txt
File name abc.txt cannot be found
Please enter file name: abab
File name abab cannot be found
Please enter file name: chsample.txt
Words and frequency in the file chsample.txt sorted alphabetically
a
all
almost
an
and
any
are
as
association
avoid
be
because
between
build
builtin
but
called
can
computer
corresponding
creates
dict
dictionary
different
each
elements
english
example
fact
from
function
general
get
have
if
in
index
indexed
indices
instead
integer
integers
is
it
item
items
key
keys
keyvalue
like
list
look
mapping
maps
might
more
name
never
new
no
not
of
on
or
order
pair
pairs
positions
problem
result
same
set
should
so
sometimes
spanish
strings
that
that's
the
think
to
type
unpredictable
up
use
using
value
values
variable
we'll
which
with
words
you
your
There are different words in the file.
Do you want to try another file? y or nY
Please enter file name: chsampletxt
Words and frequency in the file chsampletxt sorted alphabetically
a
all
almost
an
and
any
are
as
association
avoid
be
because
between
build
builtin
but
called
can
creates
dict
dictionary
don't
each
english
example
from
function
general
have
in
index
indices
integers
is
it
item
items
key
keys
keyvalue
like
list
mapping
maps
more
name
new
no
of
or
pair
positions
set
should
so
sometimes
spanish
strings
that
the
think
to
type
using
value
values
variable
we'll
which
with
words
you
There are different words in the file.
Do you want to try another file? y or nN
Thank you for playing.
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
