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
weeeeeb [17]
3 years ago
15

Here's something to stop you from getting repetitive when writing essays. Write a program that reads multiple lines of plain tex

t from the user, then prints out each different word in the input with a count of how many times that word occurs. Don't worry about punctuation or case – the input will just be words, all in lower case. Your output should list the words in alphabetical order.

Computers and Technology
1 answer:
Marianna [84]3 years ago
7 0

Answer:

The output is attached below

Explanation:

d = {}

while True:

line = input("Enter line: ")

if len(line)==0:

break

token = line.split(' ')

for var in token:

try:

if len(var)==0:

continue

count = d[var]

d[var] = count + 1

except KeyError:

d[var] = 1

pass

for word in sorted(d):

print(word , d[word])

------------------

You might be interested in
Write a function: function solution(N); that, given a positive integer N, prints the consecutive numbers from 1 to N, each on a
koban [17]

Answer:

<em>The program written in Python is as follows:</em>

def solution(N):

     concat = ""

     for i in range(1,N+1):

           if not(i%2 == 0 or i%3 ==0 or i%5 == 0):

                 print(str(i))

           else:

                 if i%2 == 0:

                       concat= concat+"Codility"

                 if i%3 == 0:

                       concat= concat+"Testers"

                 if i%5 == 0:

                       concat= concat+"Coders"

                 print(concat)

                 concat = ""

N = int(input("Enter a positive integer: "))

solution(N)

Explanation:

This line declares the function

def solution(N):

This line initializes a variable named concat to an empty string

     concat = ""

This line iterates from 1 to the input integer

     for i in range(1,N+1):

<em>This line checks if the current number of iteration is divisible by 2,3 or 5, if no, the number is printed</em>

           if not(i%2 == 0 or i%3 ==0 or i%5 == 0):

                 print(str(i))

<em>If otherwise</em>

           else:

<em>This lines checks if current number is divisible by 2; if yes the string "Codility" is concatenated to string concat</em>

                 if i%2 == 0:

                       concat= concat+"Codility"

<em>This lines checks if current number is divisible by 3; if yes the string "Testers" is concatenated to string concat</em>

<em>                 </em> if i%3 == 0:

                       concat= concat+"Testers"

<em>This lines checks if current number is divisible by 2; if yes the string "Coders" is concatenated to string concat</em>

                 if i%5 == 0:

                       concat= concat+"Coders"

<em>The concatenated string is printed using this line</em>

                 print(concat)

This variable concat is intialized back to an empty string

                 concat = ""

The main method starts here

N = int(input("Enter a positive integer: "))

This line calls the defined function solution

solution(N)

6 0
3 years ago
Do all light bulbs server a practical purpose?
Greeley [361]

Answer:

A light bulb produces light from electricity

6 0
3 years ago
When using social​ media, make sure to provide access to all the information needed to accurately process messages by following
Nataly_w [17]

Answer:

Option E i.e., transparency is the correct option.

Explanation:

When any person using social media networks the he always ensure that he gives all the information related accurately about himself because in the social media network there is the transparency of everything except his chat with other but any person get details of the other person only if he is using social media network.

4 0
3 years ago
1. Bones do not change position when the muscles contract and release.
DochEvi [55]
TrueBones do not change position
6 0
3 years ago
When using a line graph, why is it inportant to only graph 1 - 3 series of data?. A. A line graph in Microsoft Excel will not al
ElenaW [278]
The most necessary point you need to follow when using a line graph, is to make your graph readable. So, the reason why is it inportant to only graph 1 - 3 series of data is that more than 3 series of data causes too many lines on the graph, which makes ti confusing to read. The last option is the correct one.
8 0
3 years ago
Other questions:
  • Cloud computing service providers manage different computing resources based on the services they offer. Which resources do IaaS
    11·1 answer
  • Describe the role of the microprocessor in an automatic washing<br> machine (IGCSE)
    10·1 answer
  • ITS MAKING ME TYPE URL CODES NOW!
    6·1 answer
  • Given the following while() loop, which statement is true assuming A,B,C,D are int variables and A &gt; B? while ( ( A &gt;= B)
    8·1 answer
  • What are the different nail disorders?
    13·1 answer
  • What do you expect the future trends of an operating system in terms of (a) cost (b) size (c) multitasking (d) portability (e) s
    12·1 answer
  • D. DROP
    6·1 answer
  • Edhesive 7.6 lesson practice python
    11·1 answer
  • what is a program or collection of programs that enable a person to manipulate a visual images on a computer​
    14·1 answer
  • An operating system with _____ capabilities allows a user to run more than one program concurrently.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!