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
harina [27]
3 years ago
7

Python3

Computers and Technology
1 answer:
Tems11 [23]3 years ago
8 0

Answer:

Following are the program in the Python Programming Language:

def countLetter(words):

   #set dictionary

 di = {}

 for i in words: #set for loop

 #if key exists in di or not

   if di.get(i):

 #if exists count increased

     di[i] += 1

   else: #otherwise assign with key

     di[i] = 1

   # return di

 return di

def main():

 #get input from the user

 words = input("Enter the word: ")

 #store the output in function

 letter = countLetter(words)

 #set for loop

 for i in letter:

   print(i, ":", letter[i])  #print output with :

#call main method

if __name__ == "__main__":

 main()

Explanation:

Here, we define the function "countLetter()" and pass the argument "words" in parameter and inside it.

  • we set the dictionary data type variable "di".
  • we set the for loop and pass the condition inside it we set if statement and increment in di otherwise di is equal to 1.
  • we return the variable di.

Then, we define the function "main()" inside it.

  • we get input from the user in the variable "words".
  • we store the return value of function "countLetter()" in the variable "letter".
  • we set for loop to print the output.

Finally, we call the main method.

You might be interested in
Which of the following is another term for a subfolder​
marin [14]

Answer:

below

Explanation:

subdirectory

5 0
3 years ago
: Write a function "def countWords(string)" that returns a count of all words in an input string represented by the variable 'st
Zina [86]
We can define a word as a group of characters without a space between them. To find the words of the input string , w can use split(delimiter) which returns a list of strings which had the defined delimiter between them in the input string.

def countWords(string):
words = string.split(" ")
count = len(words)
return count

Here we set the delimiter as the space character, and returned the length of the words list. I split each step into its own line for readability, however the function could be one line:

return len(string.split())

Here, no delimiter is specified. If one isn't given, it will default to split at any whitespace, including space.

3 0
3 years ago
Is a storyboard an example of an implemation tool?
goblinko [34]
Yes, the answer is true.
8 0
3 years ago
Read 2 more answers
How do u friend people
Verdich [7]
You click on the three dots and click the person silhouette with the plus sign on it.
4 0
3 years ago
Read 2 more answers
What type of stud is placed below a windowsill to support its weight
Vesnalui [34]
A <span>cripple stud is what is use for windows and doors 

</span>
6 0
3 years ago
Other questions:
  • Your boss wants to utilize some sort of cloud storage for his files so that all of his
    10·2 answers
  • Study the sentences below. A.Changing the properties of characters in a sentence or paragraph in a Word document helps increase
    5·2 answers
  • What is the point of brainy when other people have to answer your questions but not the cumputer
    9·1 answer
  • While (e &lt; 10):<br> print (c)
    10·1 answer
  • Which of the following popular presentation software items do you have to purchase in order to use?
    11·2 answers
  • Role of memory in a computer system
    10·1 answer
  • Write a method named addCommas that accepts a string representing a number and returns a new string with a comma at every third
    10·1 answer
  • PLEASE I NEED HELP WITH THIS, IS FOR TODAY
    10·2 answers
  • Type the correct answer in each box. Spell all words correctly, and use numerals instead of words for numbers. If necessary, use
    6·1 answer
  • Which sentence describe internet safety precautions?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!