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
bagirrra123 [75]
3 years ago
14

Create a dictionary named letter_counts that contains each letter and the number of times it occurs in string1. Challenge: Lette

rs should not be counted separately as upper-case and lower-case. Intead, all of them should be counted as lower-case.
Computers and Technology
1 answer:
Amanda [17]3 years ago
4 0

Answer:

  1. letter_counts = {}
  2. string1 = "I have a dream"
  3. string1 = string1.lower()
  4. for x in string1:
  5.    if(x == " "):
  6.        continue  
  7.    if x not in letter_counts:
  8.        letter_counts[x] = 1
  9.    else:
  10.        letter_counts[x] += 1
  11. print(letter_counts)

Explanation:

The solution is written in Python 3.

Firstly create a letter_count dictionary (Line 1)

Next, create a sample string and assign it to string1 variable and convert all the characters to lowercase using lower method (Line 4).

Create a for loop to traverse through each character in string1 and check if the current character is a single space, just skip to the next iteration (Line 7 -8). If the current character is not found in letter_counts dictionary, set the initial count value 1 to x property of letter_counts. Otherwise increment the x property value by one (Line 9 -12).

After completion of loop, print the letter_count dictionary. We shall get the sample output {'i': 1, 'h': 1, 'a': 3, 'v': 1, 'e': 2, 'd': 1, 'r': 1, 'm': 1}

You might be interested in
What are the four different orchestral instrument families?
natka813 [3]

Answer:

Gutair

Violen

cello

Double Brass

Harp

Explanation:

7 0
3 years ago
Read 2 more answers
What term describes data actions being performed by endpoint devices, such as printing a report from a desktop computer?
Sloan [31]

Answer:

The correct answer to the following question will be "Data-in-use".

Explanation:

  • Data-in-use is an IT term referring to active information that is usually preserved in a semi-persistent physical state in RAM of computer, CPU registers or caches.
  • It might be created, modified or changed, deleted or accessed via different endpoints of the interface. This is indeed a useful term for IT departments to pursue institutional defense.

Therefore, it's the right answer.

4 0
2 years ago
The Joint Photographic Experts Group developed the ___________ graphic format.
jolli1 [7]
1. <span>The Joint Photographic Experts Group developed the jpeg graphic format. 
2. </span><span>It is important to include the alt attribute of the tag because some people use text-only Web browsers. </span>
4 0
3 years ago
Read 2 more answers
Consider an online shopping portal that allows a customer to browse and purchase different products. The products are arranged u
o-na [289]
Way too much to read bye
7 0
2 years ago
Read 2 more answers
At your job, you often have to address letters to the customer support manager, Tyson Kajewski. The problem is that you are cons
krek1111 [17]
Input his name in the dictionary function, you can also copy the given name an paste as much as you need
5 0
3 years ago
Other questions:
  • Read three integers from user input. Then, print the product of those integers. Ex: If input is 2 3 5, output is 30. Note: Our s
    6·1 answer
  • Zach wants to learn a programming language to create games and applications. this programming language will also create web appl
    12·2 answers
  • Which of the following are valid values for a boolean value in programming? (Select all that apply)
    8·1 answer
  • What xDSL version provides a maximum throughput of 24 Mbps downstream and 3.3 Mbps upstream?
    9·1 answer
  • When looking at a relationship between two tables on an ERD, the _____ table can be identified by the presence of a foreign key
    8·1 answer
  • How would you define media literacy?
    12·1 answer
  • Convert each of the fo" wing base ten representations to its equivalent binary form a. 6 b. 13 C. d. 18 e. 27
    6·1 answer
  • What is the difference of expository and reflexive documentary
    14·1 answer
  • Bro i swear whenever i play fortnite duos, they ask you if you don't have a mic, if you don't then they just leave, so annoying
    15·2 answers
  • Describe the concept behind a digital signature and explain how it relates to cybersecurity by providing a hypothetical example
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!