subject

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 !

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 20:00, Jana1517
What is the worst-case complexity of the maxrepeats function? assume that the longest string in the names array is at most 25 characters wide (i. e., string comparison can be treated as o( class namecounter { private: int* counts; int nc; string* names; int nn; public: namecounter (int ncounts, int nnames); int maxrepeats() const; }; int namecounter: : maxrepeats () { int maxcount = 0; for (int i = 0; i < nc; ++i) { int count = 1; for (int j = i+1; j < nc; ++j) { if (names[i] == names[j]) ++count; } maxcount = max(count, maxcount); } return maxcount; }
Answers: 3
image
Computers and Technology, 22.06.2019 20:00, ayoismeisalex
When you mouse over and click to add a search term this(these) boolean operator(s) is(are) not implied. (select all that apply)?
Answers: 1
image
Computers and Technology, 23.06.2019 09:30, cdavis379
:you areto design the controller for alight that functions both as an ordinary light and also as a motion activated light and alarm. a. if the manual switch s is on, then the light l is on. b. besides the manual switch, there is a motion detector, m1, which activatesthis light. c.if motion is detected but the light is on anyway because s is on, only then a secondoutput a, an alarm, is turned on. d. the disable switch, d, disables the motion activated light and alarmbut leaves manual control operation of the light using switch s.(i)read the problem statement and clearly identify the inputs and outputs for the circuit you are designing. (ii)create the truth table for this system; include the light, alarm, switch, disable, and the motion sensor.(iii)draw a schematic of this system.
Answers: 1
image
Computers and Technology, 23.06.2019 16:30, 19thomasar
How to do this programming flowchart?
Answers: 3
You know the right answer?
Exercise 1a
* import the string library.
* create a variable alphabet that consists of...

Questions in other subjects:

Konu
Mathematics, 04.12.2020 20:30