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
Describe how web caching can reduced the delay in receiving a requested object .Will web caching reduce the delay for all object
nydimaria [60]

Answer:

Web caching can bring the desired content "closer" to the user, perhaps to the same LAN to which the user's host is connected. Web caching can reduce the delay for all objects, even objects that are not cached, since caching reduces the traffic on links

Explanation:

8 0
3 years ago
Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five int
Aloiza [94]

Using the knowledge in computational language in JAVA it is possible to write a code that  print the respective minimum and maximum values as a single line

<h3>Writting the code in JAVA:</h3>

<em>import java.io.*;</em>

<em>import java.util.*;</em>

<em>import java.text.*;</em>

<em>import java.math.*;</em>

<em>import java.util.regex.*;</em>

<em />

<em>public class Solution {</em>

<em>    public static void main(String[] args) {</em>

<em>        Scanner in = new Scanner(System.in);</em>

<em>        long sum = 0;</em>

<em>        long max = Long.MIN_VALUE;</em>

<em>        long min = Long.MAX_VALUE;</em>

<em>        for (int i = 0; i < 5; i++){</em>

<em>            long n = in.nextLong();</em>

<em>            sum += n;</em>

<em>            max = Math.max(max, n);</em>

<em>            min = Math.min(min, n);</em>

<em>        }</em>

<em>        System.out.println((sum - max) + " " + (sum - min));</em>

<em>    }</em>

<em>}</em>

See more about JAVA at brainly.com/question/12974523

#SPJ1

8 0
2 years ago
In python how do you write for prime factors
olasank [31]

Answer:

The while loop is used and the factors of the integer are computed by using the modulus operator and checking if the remainder of the number divided by i is 0. 3. Then the factors of the integer are then again checked if the factor is prime or not.

Explanation:

google

4 0
3 years ago
Your sister is starting 9th grade next year and is thinking about going to college. What step would you recommend she take first
Cloud [144]
Focusing on school and her grades and graduating before she starts thinking about collage
5 0
3 years ago
Read 2 more answers
if you want to prevent slides to fellow students or coworkers which productivity software would you should you use to create the
Vikki [24]
One program used for presenting slides to people is Microsoft Powerpoint.
7 0
3 years ago
Read 2 more answers
Other questions:
  • A(n) ____ tag is used to let the compiler know that your intention is to override a method in a parent class
    10·1 answer
  • What is alphabet symmetry
    12·2 answers
  • 2h2 + o2 → 2h2o<br> pls i need help
    10·1 answer
  • How Much Memory Did the First Computers Have?
    5·1 answer
  • 6.Which of the following statements illustrates a characteristic of a person's attitudes
    14·2 answers
  • Use of the Internet for e-government has increased. Identify the benefits by checking all of the boxes that apply.
    8·1 answer
  • Which measurement symbol is this?<br>PLS HELP<br>​
    14·1 answer
  • Additional rows and columns are inserted into a table using the
    6·1 answer
  • What is<br> a an<br> output device
    10·1 answer
  • A(n) _____ is the software that enables the os to control a device.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!