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
ozzi
3 years ago
13

Def build_dictionary(string):

Computers and Technology
1 answer:
MissTica3 years ago
4 0

Answer:

Follows are the code to this question:

def build_word_counter(string):#defining a method build_word_counter that accepts string as a parameter  

   d = dict()#defining d variable as a dictionary

   for x in string:#defining for loop that use string

       x = x.lower()#Use lower method  

       if not d.get(x):#defining if block that holds value in d variable

           d[x] = 1#use dictionary to hold value in 1

       else:#defining else block

           d[x] += 1#use dictionary to increment value by 1

   return d#return dictionary

print(build_word_counter(["Like","like","LIKE"]))#use print method to call method

def build_letter_distribution(string):#defining a method build_letter_distribution that accepts string variable

   d = dict()#defining d variable as a dictionary

   for i in string:#defining for loop to count string value

       for j in i:#defining for loop to hold string as number

           if not d.get(j):#defining if block that doesn't get value in dictionary  

               d[j] = 1#hold value in dictionary  

           else:#defining else block

               d[j] += 1#use dictionary to increment the dictionary value

   return d#return dictionary

print(build_letter_distribution(["Like","test","abcdEFG"]))#use print method to return its value

Output:

please find the attached file.

Explanation:

In the first program a method, "build_word_counter" is defined that accepts a string variable in its parameter, and inside the method, a dictionary variable "d" is defined that uses the for loop to hold string value and convert all value into lower case.

In the next step, a conditional statement is used that holds value in the dictionary and count its word value.

In the second program a method, "build_letter_distribution" is defined that holds string variable in its parameter, and inside the method, a dictionary variable "d" is defined that uses the two for loop and in if the block, it holds value in the dictionary and returns its value, and use print method to print its return its value.

You might be interested in
A collision volume is called ____
Phoenix [80]

C IS THE CORRECT ANSWER NOT A I PROMISE ITS REGION!!!

6 0
3 years ago
What characteristics of IT careers can be a challenge for employees
IRINA_888 [86]

It is essential to continually be learning about new technology.(APEX VERIFIED)

8 0
3 years ago
Read 2 more answers
In Microsoft Word you can access the _______ command from the "Mini toolbar".
xenn [34]
I think the answer is save as
4 0
4 years ago
What is the process in which a server is partitioned into smaller components
Usimov [2.4K]
I believe the answer to this is server virtualization.
4 0
4 years ago
Wat is a computer risk<br>​
klemol [59]

Answer:

Virus, cyber theft

Explanation:

A computer risk is something that can potentially harm your data on your computer or harm you through a computer by using theft tactics from real people to autonomous viruses making it to your computer and slowing your computer. With cybrrtheft thieves can get personal info through accounts to pictures and payment information.

4 0
4 years ago
Read 2 more answers
Other questions:
  • How does hardware differ from software
    9·1 answer
  • What is output with the statement System.out.println(x+y); if x and y are int values where x=10 and y=5? Group of answer choices
    10·1 answer
  • For this lab, youhave to write a programnamedseriesFunction.cthat prompts user to enter two values, x and n. Then it would use a
    11·1 answer
  • The narrative structure of the popular movies can be broken down into
    15·1 answer
  • Shania has started a new job as an app developer. Her first task was to make an old app designed for Android available on other
    9·1 answer
  • Question 14 (3 points)
    5·1 answer
  • How do you use a iPad when it has a password ?
    9·2 answers
  • If you have a 99% and you got a 50 on a test what is the grade please I will give brainless
    7·2 answers
  • UDAL Pretest: Using Digital Cameras 15 Select the correct answer. Which mode of shutter speed helps to capture creative effects
    6·1 answer
  • Answer if you know Javascript, html, css, python, and Ruby.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!