1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Lesechka [4]
3 years ago
14

1. Please write the following code in Python 3.2. Please also show all outputs.Create a dictionary named letter_counts that cont

ains each letter and the number of times it occurs in string1. Challenge: Letters should not be counted separately as upper-case and lower-case. Intead, all of them should be counted as lower-case.string1 = "There is a tide in the affairs of men, Which taken at the flood, leads on to fortune. Omitted, all the voyage of their life is bound in shallows and in miseries. On such a full sea are we now afloat. And we must take the current when it serves, or lose our ventures."
Computers and Technology
1 answer:
nevsk [136]3 years ago
4 0

Answer:

string1="There is a tide in the affairs of men, Which taken at the flood, leads on to fortune. Omitted, all the voyage of their life is bound in shallows and in miseries. On such a full sea are we now afloat. And we must take the current when it serves, or lose our ventures."

string1=string1.lower()   #covert whole string to lowercase

letter_counts={}

for ch in string1:

   letter_counts[ch]=letter_counts.get(ch,0)+1   #updates counter for each letter

letter_counts['o']

OUTPUT :

17

Explanation:

lower() is used to change the string to lowercase characters so that uppercase and lowercase is not differentiated for the same letter. After that, letter_counts is declared as a dictionary which is empty. for loop is used in which every letter of string will be stored ch variable. Dictionary in python has a get method in which 2 arguments can be passed, first one is the key whose value to be retrieved and the other argument would be default value to be set if not found and ch in string1 will increment the value of key ch in letter_counts.

You might be interested in
How do I get rid of this little tool bar????
Serhud [2]

Answer:

settings>Accessibility>Touch>AssistiveTouch>Turn off

Explanation:

4 0
3 years ago
Who watched Unus Annus??? (If you did what was your favorite part?​
quester [9]

This video was completeley unedited was a banger, and so was the vid where they made robot amy. that was hilarious.

But since it is now Post Mortem all say here is...

Unas Annus. Memento Mori.

It sure was fun.

3 0
3 years ago
PLEASE HELP!
Basile [38]

Answer:

declare count as integer

7 0
3 years ago
Which of the following is true about science and technology?
kow [346]

Answer:

A

Explanation:

6 0
3 years ago
When workers demonstrate patience, are able to manage there emotions, and get along with other employees, which skills are being
LenKa [72]
The skill thar is being displayed I thing is being outgoing and loyal
6 0
3 years ago
Read 2 more answers
Other questions:
  • What process improves the life of a computer
    11·1 answer
  • I don't know the answer and I tried different ones and they not what the book is looking for.
    7·1 answer
  • In a Comparative Government course, the first unit focuses on the US Congress and the
    8·1 answer
  • An ftp ____ is a computer that allows users to upload and/or download files using ftp.
    5·1 answer
  • 2. Use inheritance to create a hierarchy of Exception classes -- EndOfSentenceException, PunctuationException, and CommaExceptio
    6·1 answer
  • Please help ASAP, will mark brainliest!
    13·1 answer
  • How is a microkernel architecture different from a monolithic architecture?
    5·1 answer
  • Assume that you have created a class named DemoCar. Within the Main() method of this class, you instantiate a Car object named m
    12·1 answer
  • 5.
    9·1 answer
  • _____ oversee the work of various types of computer professionals and must be able to communicate with people in technical and n
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!