Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 1A * Import the string library. * Create a variable alphabet that consists of the lowercase and uppercase letters in the English alphabet using

Exercise 1A * Import the string library. * Create a variable alphabet that consists of the lowercase and uppercase letters in the English alphabet using the ascii_letters attribute of the string library.

Exercise 1B * The lower and upper cases of the English alphabet is stored as alphabet. * Consider the sentence 'Jim quickly realized that the beautiful gowns are expensive'. Create a dictionary count_letters with keys consisting of each unique letter in the sentence and values consisting of the number of times each letter is used in this sentence. Count both upper case and lower case letters separately in the dictionary.

sentence = 'Jim quickly realized that the beautiful gowns are expensive' count_letters = {}

Exercise 1C * Comment your code from 1b to make a function called counter that takes a string input_string and returns a dictionary of letter counts count_letters. * Use your function to call counter(sentence)

Exercise 1D * Abraham Lincoln was a president during the American Civil War. His famous 1863 Gettysburg Address has been stored as address, and the counter function defined in part 1c has been loaded. Use these to return a dictionary consisting of the count of each letter in this address, and save this as address_count. * Print address_count address = 'Abraham Lincoln was a president during the American Civil War. His famous 1863 Gettysburg Address'

Exercise 1E * The frequency of each letter in the Gettysburg Address is already stored as address_count. Use this dictionary to find the most common letter in the Gettysburg address. * Store this letter as most_frequent_letter, and print your answer.

Use python for all above!!!

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

Build It For The Real World A Database Workbook

Authors: Wilson, Susan, Hoferek, Mary J.

1st Edition

0073197599, 9780073197593

More Books

Students also viewed these Databases questions