Posting together because they are related. Python 1. Create a program to count the number of occurrences...

80.2K

Verified Solution

Question

Programming

Posting together because they are related.

Python

1. Create a program to count the number of occurrences of eachletter of the alphabet in a text file, and print out the total foreach letter (if greater than 0). Ignore numbers, punctuation, andspecial characters. Make sure to treat capital and lowercaseletters as occurrences of the same letter. The text file(sample_text.txt) is attached to the assignment.

Example: For the text \"My dog's name is Winston.\" The resultswould be:

A - 1

D - 1

E - 1

G - 1

I - 2

M - 2

N - 3

O - 2

S - 3

T - 1

W - 1

Y - 1

2. Rewrite # 1 above using a dictionary to hold each alphabeticcharacter as a key, and the count of the characters as the value.Reuse as much of the code from #1 as you can! However, usedifferent variable names to prevent errors caused by using the samenames. (5 pts.)

Answer & Explanation Solved by verified expert
4.1 Ratings (780 Votes)
I have uploaded the Images of the code Typed code and Output ofthe Code I have provided explanation using comments read them forbetter understandingProgram 1Images of the CodeNote If the below code is missing indentation pleaserefer code ImagesTyped Code reading File name from user comment below line if not required and pass File name in open    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students