Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This program is about dictionaries. We want to use a dictionary to store frequency count of each letter in a string. Write a Python program

This program is about dictionaries. We want to use a dictionary to store frequency count of each letter in a string. Write a Python program to do the following:

(a) Ask the user to enter a string. Convert all letters to uppercase. Count the frequency of each letter in the string. Store the frequency counts in a dictionary. You should count letters only. Do not count any other characters such as digits and space. Display the dictionary.

(b) Ask the user to enter a letter. Convert it to uppercase. Check whether the letter is in the dictionary. If it is not, display the message Letter not in dictionary. Otherwise, display the frequency count of that letter, remove the letter from the dictionary and display the dictionary after that letter has been removed.

(c) Create a list to store the letters that are in the dictionary. Sort and display the list.

The following is an example.

Enter a string: Magee, Mississippi

Dictionary: {'M': 2, 'A': 1, 'G': 1, 'E': 2, 'I': 4, 'S': 4, 'P': 2}

Choose a letter: s

Frequency count of that letter: 4

Dictionary after that letter removed: {'M': 2, 'A': 1, 'G': 1, 'E': 2, 'I': 4, 'P': 2}

Letters sorted: ['A', 'E', 'G', 'I', 'M', 'P']

Please write code in pycharm or something similar

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design And Implementation

Authors: David M. Kroenke

5th Edition

B000CSIH5A, 978-0023668814

Students also viewed these Databases questions