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 file system below does not support encryption, file based compression, and disk quotas, but does support extremely large v
Elena L [17]

Answer:

D.  ReFS

Explanation:

File system is simply a management system for files that controls how and where data are stored, where they can be located and how data can be accessed. It deals with data storage and retrieval.

Examples of file system are NTFS, FAT(e.g FAT 16 and FAT 32), ReFS.

ReFS, which stands for Resilient File System, is designed primarily to enhance scalability by allowing for the storage of extremely large amounts of data and efficiently manage the availability of the data. It is called "resilient" because it ensures the integrity of data by offering resilience to data corruption. It does not support transaction, encryption, file based compression, page file and disk quotas, to mention a few.

6 0
2 years ago
You can italicize a word by selecting it and clicking the italics icon. what keyboard shortcut could you use instead of clicking
andrew-mc [135]
CTRL+i, press them at the same time

8 0
3 years ago
Read 2 more answers
What is your perception of what a safe classroom looks like
Andreyy89

Answer:

6 feet apart

Explanation:

6 0
3 years ago
Identify the menu under which you'll find the Header and Footer option.
Genrish500 [490]

The answer is B. View.

4 0
2 years ago
(1) Prompt the user to enter five numbers, being five people's weights. Store the numbers in an array of doubles. Output the arr
Mashutka [201]

Answer:

weights = []

total = 0

max = 0

for i in range(5):

   weight = float(input("Enter weight " + str(i+1) + ": "))

   weights.append(weight)

   total += weights[i]

   if weights[i] > max:

       max = weights[i]

average = total / 5

print("Your entered: " + str(weights))

print("Total weight: " + str(total))

print("Average weight: " + str(average))

print("Max weight: " + str(max))

Explanation:

Initialize the variables

Create a for loop that iterates 5 times

Get the values from the user

Put them inside the array

Calculate the total by adding each value to the total

Calculate the max value by comparing each value

When the loop is done, find the average - divide the total by 5

Print the results

6 0
3 years ago
Other questions:
  • What task can a user accomplish by customizing theme colors?
    14·2 answers
  • A client accessing a network share folder has authenticated into the system and has full access rights to a folder share. But af
    11·1 answer
  • The Apple II is an IBM-compatible PC "clone".<br> True?<br> False?
    10·1 answer
  • Your program is going to compare the distinct salaries of two individuals for the last 5 years. If the salary for the two indivi
    15·1 answer
  • EDVAC stands for? on which theory it is made on?
    15·1 answer
  • A technician wants to consolidate and log specific alerts from network devices into a database so maintenance tasks and potentia
    11·1 answer
  • Which activity represents a violation of the licensing agreement?
    13·2 answers
  • For this scenario related to turtle drawing, indicate whether it is better to write a loop or a function (or a set of functions)
    13·1 answer
  • Which among the following choices is correct based on the two statements listed below? Statement 1: When the lexical analyzer sc
    12·1 answer
  • 23. ____________ is a slide that is used as the base design theme for other slides.​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!